@anvia/studio 0.7.34 → 0.7.35

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 (51) hide show
  1. package/dist/index.d.ts +54 -1
  2. package/dist/index.js +292 -8
  3. package/dist/index.js.map +1 -1
  4. package/dist/ui/assets/{PathIcon-DX1w_Nk9.js → PathIcon-B7p7vF2d.js} +1 -1
  5. package/dist/ui/assets/{PathIcon-DX1w_Nk9.js.map → PathIcon-B7p7vF2d.js.map} +1 -1
  6. package/dist/ui/assets/{PlayIcon-Culan3xL.js → PlayIcon-Dt2gGfiW.js} +1 -1
  7. package/dist/ui/assets/{PlayIcon-Culan3xL.js.map → PlayIcon-Dt2gGfiW.js.map} +1 -1
  8. package/dist/ui/assets/{RefreshIcon-B3w42HZJ.js → RefreshIcon-BOrxG7tt.js} +1 -1
  9. package/dist/ui/assets/{RefreshIcon-B3w42HZJ.js.map → RefreshIcon-BOrxG7tt.js.map} +1 -1
  10. package/dist/ui/assets/{agents-page-nyn87qWN.js → agents-page-BdDnlVyJ.js} +2 -2
  11. package/dist/ui/assets/{agents-page-nyn87qWN.js.map → agents-page-BdDnlVyJ.js.map} +1 -1
  12. package/dist/ui/assets/{badge-BH7gz3tB.js → badge-CeTBFuRX.js} +1 -1
  13. package/dist/ui/assets/{badge-BH7gz3tB.js.map → badge-CeTBFuRX.js.map} +1 -1
  14. package/dist/ui/assets/chunk-FE5QL4G3-C1KRmMy_.js +2 -0
  15. package/dist/ui/assets/chunk-FE5QL4G3-C1KRmMy_.js.map +1 -0
  16. package/dist/ui/assets/{evals-page-CHxft1PA.js → evals-page-1QJywSGG.js} +2 -2
  17. package/dist/ui/assets/{evals-page-CHxft1PA.js.map → evals-page-1QJywSGG.js.map} +1 -1
  18. package/dist/ui/assets/index-BncPUHdf.css +1 -0
  19. package/dist/ui/assets/index-DsFqmLt-.js +55 -0
  20. package/dist/ui/assets/index-DsFqmLt-.js.map +1 -0
  21. package/dist/ui/assets/{knowledge-page-BIphUowG.js → knowledge-page-Bh0HYSnR.js} +2 -2
  22. package/dist/ui/assets/{knowledge-page-BIphUowG.js.map → knowledge-page-Bh0HYSnR.js.map} +1 -1
  23. package/dist/ui/assets/{mcps-page-CEyvZfpe.js → mcps-page-BoMVJjHL.js} +2 -2
  24. package/dist/ui/assets/{mcps-page-CEyvZfpe.js.map → mcps-page-BoMVJjHL.js.map} +1 -1
  25. package/dist/ui/assets/memory-page-B-LtyVhA.js +4 -0
  26. package/dist/ui/assets/memory-page-B-LtyVhA.js.map +1 -0
  27. package/dist/ui/assets/{pipelines-page-BllEnKpu.js → pipelines-page-DeIlIHCP.js} +2 -2
  28. package/dist/ui/assets/{pipelines-page-BllEnKpu.js.map → pipelines-page-DeIlIHCP.js.map} +1 -1
  29. package/dist/ui/assets/{renderers-Dzjh-nGh.js → renderers-IW2ZAJZw.js} +1 -1
  30. package/dist/ui/assets/{renderers-Dzjh-nGh.js.map → renderers-IW2ZAJZw.js.map} +1 -1
  31. package/dist/ui/assets/{sandboxes-page-B8GcUS5f.js → sandboxes-page-B_Lf-UtP.js} +2 -2
  32. package/dist/ui/assets/{sandboxes-page-B8GcUS5f.js.map → sandboxes-page-B_Lf-UtP.js.map} +1 -1
  33. package/dist/ui/assets/{sessions-page-BY2ysr2u.js → sessions-page-DjAuU-RX.js} +2 -2
  34. package/dist/ui/assets/{sessions-page-BY2ysr2u.js.map → sessions-page-DjAuU-RX.js.map} +1 -1
  35. package/dist/ui/assets/{status-page-CZ0HBJY5.js → status-page-BaDIKvef.js} +2 -2
  36. package/dist/ui/assets/{status-page-CZ0HBJY5.js.map → status-page-BaDIKvef.js.map} +1 -1
  37. package/dist/ui/assets/{tool-runner-CkQ3WBw4.js → tool-runner-C5vzRzrt.js} +2 -2
  38. package/dist/ui/assets/{tool-runner-CkQ3WBw4.js.map → tool-runner-C5vzRzrt.js.map} +1 -1
  39. package/dist/ui/assets/{tools-page-CmVAorUe.js → tools-page-ClNVTM2F.js} +2 -2
  40. package/dist/ui/assets/{tools-page-CmVAorUe.js.map → tools-page-ClNVTM2F.js.map} +1 -1
  41. package/dist/ui/assets/{trace-browser-DekV4BNP.js → trace-browser-BQ_YWG4y.js} +2 -2
  42. package/dist/ui/assets/{trace-browser-DekV4BNP.js.map → trace-browser-BQ_YWG4y.js.map} +1 -1
  43. package/dist/ui/assets/{transcript-item-CQCD2CY3.js → transcript-item-CdsVcgad.js} +2 -2
  44. package/dist/ui/assets/{transcript-item-CQCD2CY3.js.map → transcript-item-CdsVcgad.js.map} +1 -1
  45. package/dist/ui/index.html +3 -2
  46. package/package.json +4 -4
  47. package/dist/ui/assets/index-DMB9ju7U.css +0 -1
  48. package/dist/ui/assets/index-DgQb2APn.js +0 -55
  49. package/dist/ui/assets/index-DgQb2APn.js.map +0 -1
  50. package/dist/ui/assets/memory-page-C2Nph26O.js +0 -2
  51. package/dist/ui/assets/memory-page-C2Nph26O.js.map +0 -1
package/dist/index.d.ts CHANGED
@@ -635,6 +635,59 @@ type StudioMemoryConversationSteps = {
635
635
  conversation: StudioMemoryConversationSummary;
636
636
  steps: StudioTranscriptEntry[];
637
637
  };
638
+ type StudioMemorySourceKind = "agent" | "studio";
639
+ type StudioMemorySourceSummary = {
640
+ ref: string;
641
+ kind: StudioMemorySourceKind;
642
+ label: string;
643
+ agentIds: string[];
644
+ available: boolean;
645
+ storeKind?: string;
646
+ reason?: string;
647
+ };
648
+ type StudioMemorySourcesPage = {
649
+ sources: StudioMemorySourceSummary[];
650
+ };
651
+ type StudioMemorySourceConversationSummary = {
652
+ ref: string;
653
+ sessionId: string;
654
+ userId: string;
655
+ agentIds: string[];
656
+ title?: string;
657
+ createdAt: string;
658
+ updatedAt: string;
659
+ messageCount: number;
660
+ metadata?: JsonObject;
661
+ };
662
+ type StudioMemorySourceConversationsPage = {
663
+ source: StudioMemorySourceSummary;
664
+ conversations: StudioMemorySourceConversationSummary[];
665
+ total: number;
666
+ };
667
+ type StudioMemorySourceUsersPage = {
668
+ source: StudioMemorySourceSummary;
669
+ users: StudioMemoryUserSummary[];
670
+ total: number;
671
+ };
672
+ type StudioMemoryMessageRecord = {
673
+ position: number;
674
+ runId: string;
675
+ turn: number;
676
+ createdAt: string;
677
+ message: Message;
678
+ };
679
+ type StudioMemorySourceConversationMessages = {
680
+ source: StudioMemorySourceSummary;
681
+ conversation: StudioMemorySourceConversationSummary;
682
+ messages: Message[];
683
+ records: StudioMemoryMessageRecord[];
684
+ transcript: StudioTranscriptEntry[];
685
+ };
686
+ type StudioMemorySourceConversationSteps = {
687
+ source: StudioMemorySourceSummary;
688
+ conversation: StudioMemorySourceConversationSummary;
689
+ steps: StudioTranscriptEntry[];
690
+ };
638
691
  type StudioStatusSummary = {
639
692
  runner: {
640
693
  id: string;
@@ -942,4 +995,4 @@ declare function createSqliteSessionStore(options?: SqliteSessionStoreOptions):
942
995
 
943
996
  declare function createInMemoryStudioStore(): StudioSessionStore & StudioTraceStore & StudioPipelineLogStore & StudioPipelineRunStore;
944
997
 
945
- export { type AgentRunRequest, type AgentRunResponse, type AgentRunStreamEvent, type AgentRunUIRequest, type AgentTraceInfo, type AgentTraceOptions, type AnviaStudio, type SqliteSessionStoreOptions, Studio, type StudioAgent, type StudioAgentConfig, type StudioAgentKnowledgeConfig, type StudioAgentMcpServerMetadata, type StudioAgentMcpToolMetadata, type StudioAgentMcpsSummary, type StudioAgentModelPolicy, type StudioAgentModelPolicyConfig, type StudioAgentModelsSummary, type StudioAgentRuntimeSummary, type StudioAgentToolApprovalMetadata, type StudioAgentToolMetadata, type StudioAgentToolSource, type StudioAgentToolsSummary, type StudioCapability, type StudioCapabilityConfig, type StudioConfig, type StudioErrorCode, type StudioErrorResponse, type StudioEvalCasePreview, type StudioEvalMetricSummary, type StudioEvalRunRequest, type StudioEvalRunResponse, type StudioEvalSuite, type StudioEvalSuiteConfig, type StudioKnowledgeEvidence, type StudioKnowledgeEvidenceDocument, type StudioKnowledgeItem, type StudioKnowledgeItemKind, type StudioKnowledgeItemsPage, type StudioKnowledgeSourceKind, type StudioKnowledgeSourceSummary, type StudioKnowledgeSummary, type StudioMemoryAppendInput, type StudioMemoryContext, type StudioMemoryConversationMessages, type StudioMemoryConversationSteps, type StudioMemoryConversationSummary, type StudioMemoryConversationsPage, type StudioMemoryErrorInput, type StudioMemoryStore, type StudioMemoryUserSummary, type StudioMemoryUsersPage, type StudioModelConfig, type StudioModelDefinition, type StudioModelModalities, type StudioModelModality, type StudioModelProvider, type StudioModelProviderConfig, type StudioModelRef, type StudioModelSummary, type StudioModelsConfig, type StudioObservabilityEvent, type StudioObservabilityEventType, type StudioOptions, type StudioPipeline, type StudioPipelineConfig, type StudioPipelineDetail, type StudioPipelineFinalEvent, type StudioPipelineLogAppendInput, type StudioPipelineLogCategory, type StudioPipelineLogEntry, type StudioPipelineLogEvent, type StudioPipelineLogLevel, type StudioPipelineLogListOptions, type StudioPipelineLogStore, type StudioPipelineReplayRequest, type StudioPipelineRunGetOptions, type StudioPipelineRunListOptions, type StudioPipelineRunRecord, type StudioPipelineRunRequest, type StudioPipelineRunResponse, type StudioPipelineRunSaveInput, type StudioPipelineRunStatus, type StudioPipelineRunStore, type StudioSandboxCapabilities, type StudioSandboxFileEntry, type StudioSandboxFileType, type StudioSandboxFilesResponse, type StudioSandboxPort, type StudioSandboxPortsResponse, type StudioSandboxProcess, type StudioSandboxProcessLogsResponse, type StudioSandboxProcessStatus, type StudioSandboxProcessesResponse, type StudioSandboxSummary, type StudioSandboxesSummary, type StudioServeLifecycleOptions, type StudioServeOptions, type StudioSession, type StudioSessionCreateInput, type StudioSessionListOptions, type StudioSessionLogAppendInput, type StudioSessionLogCategory, type StudioSessionLogEntry, type StudioSessionLogEvent, type StudioSessionLogLevel, type StudioSessionLogListOptions, type StudioSessionRunStatus, type StudioSessionRunTranscriptInput, type StudioSessionStore, type StudioSessionSummary, type StudioSessionTraceListOptions, type StudioStaticKnowledgeDocument, type StudioStatusSummary, type StudioStores, type StudioTarget, type StudioToolApproval, type StudioToolApprovalDecision, type StudioToolApprovalRequestEvent, type StudioToolApprovalResultEvent, type StudioToolApprovalStatus, type StudioToolApprovalTranscript, type StudioToolQuestion, type StudioToolQuestionAnswer, type StudioToolQuestionChoice, type StudioToolQuestionPrompt, type StudioToolQuestionRequestEvent, type StudioToolQuestionResultEvent, type StudioToolQuestionStatus, type StudioToolQuestionTranscript, type StudioToolRunRequest, type StudioToolRunResponse, type StudioTrace, type StudioTraceListOptions, type StudioTraceObservation, type StudioTraceObservationKind, StudioTraceObserver, type StudioTraceObserverOptions, type StudioTraceStatus, type StudioTraceStore, type StudioTraceSummary, type StudioTranscriptAttachment, type StudioTranscriptChatEntry, type StudioTranscriptChildAgentEvent, type StudioTranscriptEntry, type StudioTranscriptReasoningEntry, type StudioTranscriptToolEntry, type StudioUiOptions, createInMemoryStudioStore, createSqliteSessionStore, traceSummary };
998
+ export { type AgentRunRequest, type AgentRunResponse, type AgentRunStreamEvent, type AgentRunUIRequest, type AgentTraceInfo, type AgentTraceOptions, type AnviaStudio, type SqliteSessionStoreOptions, Studio, type StudioAgent, type StudioAgentConfig, type StudioAgentKnowledgeConfig, type StudioAgentMcpServerMetadata, type StudioAgentMcpToolMetadata, type StudioAgentMcpsSummary, type StudioAgentModelPolicy, type StudioAgentModelPolicyConfig, type StudioAgentModelsSummary, type StudioAgentRuntimeSummary, type StudioAgentToolApprovalMetadata, type StudioAgentToolMetadata, type StudioAgentToolSource, type StudioAgentToolsSummary, type StudioCapability, type StudioCapabilityConfig, type StudioConfig, type StudioErrorCode, type StudioErrorResponse, type StudioEvalCasePreview, type StudioEvalMetricSummary, type StudioEvalRunRequest, type StudioEvalRunResponse, type StudioEvalSuite, type StudioEvalSuiteConfig, type StudioKnowledgeEvidence, type StudioKnowledgeEvidenceDocument, type StudioKnowledgeItem, type StudioKnowledgeItemKind, type StudioKnowledgeItemsPage, type StudioKnowledgeSourceKind, type StudioKnowledgeSourceSummary, type StudioKnowledgeSummary, type StudioMemoryAppendInput, type StudioMemoryContext, type StudioMemoryConversationMessages, type StudioMemoryConversationSteps, type StudioMemoryConversationSummary, type StudioMemoryConversationsPage, type StudioMemoryErrorInput, type StudioMemoryMessageRecord, type StudioMemorySourceConversationMessages, type StudioMemorySourceConversationSteps, type StudioMemorySourceConversationSummary, type StudioMemorySourceConversationsPage, type StudioMemorySourceKind, type StudioMemorySourceSummary, type StudioMemorySourceUsersPage, type StudioMemorySourcesPage, type StudioMemoryStore, type StudioMemoryUserSummary, type StudioMemoryUsersPage, type StudioModelConfig, type StudioModelDefinition, type StudioModelModalities, type StudioModelModality, type StudioModelProvider, type StudioModelProviderConfig, type StudioModelRef, type StudioModelSummary, type StudioModelsConfig, type StudioObservabilityEvent, type StudioObservabilityEventType, type StudioOptions, type StudioPipeline, type StudioPipelineConfig, type StudioPipelineDetail, type StudioPipelineFinalEvent, type StudioPipelineLogAppendInput, type StudioPipelineLogCategory, type StudioPipelineLogEntry, type StudioPipelineLogEvent, type StudioPipelineLogLevel, type StudioPipelineLogListOptions, type StudioPipelineLogStore, type StudioPipelineReplayRequest, type StudioPipelineRunGetOptions, type StudioPipelineRunListOptions, type StudioPipelineRunRecord, type StudioPipelineRunRequest, type StudioPipelineRunResponse, type StudioPipelineRunSaveInput, type StudioPipelineRunStatus, type StudioPipelineRunStore, type StudioSandboxCapabilities, type StudioSandboxFileEntry, type StudioSandboxFileType, type StudioSandboxFilesResponse, type StudioSandboxPort, type StudioSandboxPortsResponse, type StudioSandboxProcess, type StudioSandboxProcessLogsResponse, type StudioSandboxProcessStatus, type StudioSandboxProcessesResponse, type StudioSandboxSummary, type StudioSandboxesSummary, type StudioServeLifecycleOptions, type StudioServeOptions, type StudioSession, type StudioSessionCreateInput, type StudioSessionListOptions, type StudioSessionLogAppendInput, type StudioSessionLogCategory, type StudioSessionLogEntry, type StudioSessionLogEvent, type StudioSessionLogLevel, type StudioSessionLogListOptions, type StudioSessionRunStatus, type StudioSessionRunTranscriptInput, type StudioSessionStore, type StudioSessionSummary, type StudioSessionTraceListOptions, type StudioStaticKnowledgeDocument, type StudioStatusSummary, type StudioStores, type StudioTarget, type StudioToolApproval, type StudioToolApprovalDecision, type StudioToolApprovalRequestEvent, type StudioToolApprovalResultEvent, type StudioToolApprovalStatus, type StudioToolApprovalTranscript, type StudioToolQuestion, type StudioToolQuestionAnswer, type StudioToolQuestionChoice, type StudioToolQuestionPrompt, type StudioToolQuestionRequestEvent, type StudioToolQuestionResultEvent, type StudioToolQuestionStatus, type StudioToolQuestionTranscript, type StudioToolRunRequest, type StudioToolRunResponse, type StudioTrace, type StudioTraceListOptions, type StudioTraceObservation, type StudioTraceObservationKind, StudioTraceObserver, type StudioTraceObserverOptions, type StudioTraceStatus, type StudioTraceStore, type StudioTraceSummary, type StudioTranscriptAttachment, type StudioTranscriptChatEntry, type StudioTranscriptChildAgentEvent, type StudioTranscriptEntry, type StudioTranscriptReasoningEntry, type StudioTranscriptToolEntry, type StudioUiOptions, createInMemoryStudioStore, createSqliteSessionStore, traceSummary };
package/dist/index.js CHANGED
@@ -3830,6 +3830,8 @@ function capabilityConfig(_options, agents, pipelines, stores, sandboxCount = 0)
3830
3830
  };
3831
3831
  if (stores.sessions !== void 0) {
3832
3832
  capabilities.sessions = { enabled: true };
3833
+ }
3834
+ if (stores.sessions !== void 0 || agents.some((agent) => agent.agent.memory !== void 0)) {
3833
3835
  capabilities.memory = { enabled: true };
3834
3836
  }
3835
3837
  if (stores.traces !== void 0) {
@@ -4384,13 +4386,137 @@ async function agentMcpMetadata(agent) {
4384
4386
 
4385
4387
  // src/runtime/memory.ts
4386
4388
  var DEFAULT_USER_ID = "default";
4389
+ var USER_DISCOVERY_LIMIT = 1e3;
4390
+ function createStudioMemorySourceRegistry(agents, sessionStore) {
4391
+ const sources = [];
4392
+ const byStore = /* @__PURE__ */ new Map();
4393
+ const agentsWithoutMemory = [];
4394
+ for (const agent of agents) {
4395
+ const store = agent.agent.memory?.store;
4396
+ if (store === void 0) {
4397
+ agentsWithoutMemory.push(agent);
4398
+ continue;
4399
+ }
4400
+ const existing = byStore.get(store);
4401
+ if (existing !== void 0) {
4402
+ existing.summary.agentIds.push(agent.id);
4403
+ existing.summary.label = "Shared agent memory";
4404
+ continue;
4405
+ }
4406
+ const ref = `agent-memory-${sources.length + 1}`;
4407
+ const label = `${agent.name ?? agent.agent.name ?? agent.id} memory`;
4408
+ const kind = storeKind(store);
4409
+ const source = store.inspector === void 0 ? unavailableAgentSource(ref, label, agent.id, kind) : agentMemorySource(ref, label, agent.id, kind, store.inspector);
4410
+ sources.push(source);
4411
+ byStore.set(store, source);
4412
+ }
4413
+ if (sessionStore !== void 0 && (agentsWithoutMemory.length > 0 || agents.length === 0)) {
4414
+ sources.push(
4415
+ studioSessionSource(
4416
+ sessionStore,
4417
+ agentsWithoutMemory.map((agent) => agent.id)
4418
+ )
4419
+ );
4420
+ }
4421
+ const byRef = new Map(sources.map((source) => [source.summary.ref, source]));
4422
+ return {
4423
+ size: sources.length,
4424
+ list: () => sources.map((source) => ({ ...source.summary, agentIds: [...source.summary.agentIds] })),
4425
+ get: (ref) => byRef.get(ref)
4426
+ };
4427
+ }
4387
4428
  function registerMemoryRoutes(app, props) {
4429
+ registerMemorySourceRoutes(app, props.sources);
4430
+ if (props.sessionStore !== void 0) {
4431
+ registerLegacyMemoryRoutes(app, props.sessionStore);
4432
+ }
4433
+ }
4434
+ function registerMemorySourceRoutes(app, registry) {
4435
+ app.get(
4436
+ "/memory/sources",
4437
+ (c) => c.json({ sources: registry.list() })
4438
+ );
4439
+ app.get("/memory/sources/:sourceRef/users", async (c) => {
4440
+ const limit = parseLimit(c.req.query("limit"));
4441
+ if (limit === void 0) {
4442
+ return errorResponse(c, 400, "bad_request", "limit must be a positive integer");
4443
+ }
4444
+ const source = registry.get(c.req.param("sourceRef"));
4445
+ if (source === void 0) {
4446
+ return errorResponse(c, 404, "not_found", "Memory source not found");
4447
+ }
4448
+ if (!source.summary.available) return unavailableSourceResponse(c, source.summary);
4449
+ const conversations = await source.listConversations({ limit: USER_DISCOVERY_LIMIT });
4450
+ const userPage = memoryUsers(conversations, limit);
4451
+ return c.json({
4452
+ source: source.summary,
4453
+ users: userPage.users,
4454
+ total: userPage.total
4455
+ });
4456
+ });
4457
+ app.get("/memory/sources/:sourceRef/conversations", async (c) => {
4458
+ const limit = parseLimit(c.req.query("limit"));
4459
+ if (limit === void 0) {
4460
+ return errorResponse(c, 400, "bad_request", "limit must be a positive integer");
4461
+ }
4462
+ const source = registry.get(c.req.param("sourceRef"));
4463
+ if (source === void 0) {
4464
+ return errorResponse(c, 404, "not_found", "Memory source not found");
4465
+ }
4466
+ if (!source.summary.available) return unavailableSourceResponse(c, source.summary);
4467
+ const userId = optionalQueryString(c.req.query("userId"));
4468
+ const listOptions = { limit };
4469
+ if (userId !== void 0) listOptions.userId = userId;
4470
+ const conversations = await source.listConversations(listOptions);
4471
+ return c.json({
4472
+ source: source.summary,
4473
+ conversations,
4474
+ total: conversations.length
4475
+ });
4476
+ });
4477
+ app.get("/memory/sources/:sourceRef/conversations/:conversationRef/messages", async (c) => {
4478
+ const source = registry.get(c.req.param("sourceRef"));
4479
+ if (source === void 0) {
4480
+ return errorResponse(c, 404, "not_found", "Memory source not found");
4481
+ }
4482
+ if (!source.summary.available) return unavailableSourceResponse(c, source.summary);
4483
+ const detail = await source.getConversation(c.req.param("conversationRef"));
4484
+ if (detail === void 0) {
4485
+ return errorResponse(c, 404, "not_found", "Conversation not found");
4486
+ }
4487
+ const messages = detail.records.map((record) => record.message);
4488
+ return c.json({
4489
+ source: source.summary,
4490
+ conversation: detail.conversation,
4491
+ messages,
4492
+ records: detail.records,
4493
+ transcript: transcriptFromMessages(messages)
4494
+ });
4495
+ });
4496
+ app.get("/memory/sources/:sourceRef/conversations/:conversationRef/steps", async (c) => {
4497
+ const source = registry.get(c.req.param("sourceRef"));
4498
+ if (source === void 0) {
4499
+ return errorResponse(c, 404, "not_found", "Memory source not found");
4500
+ }
4501
+ if (!source.summary.available) return unavailableSourceResponse(c, source.summary);
4502
+ const detail = await source.getConversation(c.req.param("conversationRef"));
4503
+ if (detail === void 0) {
4504
+ return errorResponse(c, 404, "not_found", "Conversation not found");
4505
+ }
4506
+ return c.json({
4507
+ source: source.summary,
4508
+ conversation: detail.conversation,
4509
+ steps: transcriptFromMessages(detail.records.map((record) => record.message))
4510
+ });
4511
+ });
4512
+ }
4513
+ function registerLegacyMemoryRoutes(app, sessionStore) {
4388
4514
  app.get("/memory/users", async (c) => {
4389
4515
  const limit = parseLimit(c.req.query("limit"));
4390
4516
  if (limit === void 0) {
4391
4517
  return errorResponse(c, 400, "bad_request", "limit must be a positive integer");
4392
4518
  }
4393
- const sessions = await props.sessionStore.listSessions({ limit: 100 });
4519
+ const sessions = await sessionStore.listSessions({ limit: 100 });
4394
4520
  const users = /* @__PURE__ */ new Map();
4395
4521
  for (const session of sessions) {
4396
4522
  const userId = sessionUserId(session);
@@ -4405,9 +4531,7 @@ function registerMemoryRoutes(app, props) {
4405
4531
  continue;
4406
4532
  }
4407
4533
  existing.conversationCount += 1;
4408
- if (!existing.agentIds.includes(session.agentId)) {
4409
- existing.agentIds.push(session.agentId);
4410
- }
4534
+ if (!existing.agentIds.includes(session.agentId)) existing.agentIds.push(session.agentId);
4411
4535
  if (new Date(session.updatedAt).getTime() > new Date(existing.lastInteractionAt).getTime()) {
4412
4536
  existing.lastInteractionAt = session.updatedAt;
4413
4537
  }
@@ -4426,7 +4550,7 @@ function registerMemoryRoutes(app, props) {
4426
4550
  const userId = optionalQueryString(c.req.query("userId"));
4427
4551
  const listInput = { limit: 100 };
4428
4552
  if (agentId !== void 0) listInput.agentId = agentId;
4429
- const sessions = await props.sessionStore.listSessions(listInput);
4553
+ const sessions = await sessionStore.listSessions(listInput);
4430
4554
  const conversations = sessions.map(memoryConversationSummary).filter((session) => userId === void 0 || session.userId === userId).slice(0, limit);
4431
4555
  return c.json({
4432
4556
  conversations,
@@ -4434,7 +4558,7 @@ function registerMemoryRoutes(app, props) {
4434
4558
  });
4435
4559
  });
4436
4560
  app.get("/memory/conversations/:conversationId/messages", async (c) => {
4437
- const session = await props.sessionStore.getSession(c.req.param("conversationId"));
4561
+ const session = await sessionStore.getSession(c.req.param("conversationId"));
4438
4562
  if (session === void 0) {
4439
4563
  return errorResponse(c, 404, "not_found", "Conversation not found");
4440
4564
  }
@@ -4445,7 +4569,7 @@ function registerMemoryRoutes(app, props) {
4445
4569
  });
4446
4570
  });
4447
4571
  app.get("/memory/conversations/:conversationId/steps", async (c) => {
4448
- const session = await props.sessionStore.getSession(c.req.param("conversationId"));
4572
+ const session = await sessionStore.getSession(c.req.param("conversationId"));
4449
4573
  if (session === void 0) {
4450
4574
  return errorResponse(c, 404, "not_found", "Conversation not found");
4451
4575
  }
@@ -4455,6 +4579,149 @@ function registerMemoryRoutes(app, props) {
4455
4579
  });
4456
4580
  });
4457
4581
  }
4582
+ function agentMemorySource(ref, label, agentId, storeKindValue, inspector) {
4583
+ const summary = {
4584
+ ref,
4585
+ kind: "agent",
4586
+ label,
4587
+ agentIds: [agentId],
4588
+ available: true
4589
+ };
4590
+ if (storeKindValue !== void 0) summary.storeKind = storeKindValue;
4591
+ return {
4592
+ summary,
4593
+ async listConversations(options) {
4594
+ const inspectorOptions = {
4595
+ limit: options.userId === DEFAULT_USER_ID ? USER_DISCOVERY_LIMIT : options.limit
4596
+ };
4597
+ if (options.userId !== void 0 && options.userId !== DEFAULT_USER_ID) {
4598
+ inspectorOptions.userId = options.userId;
4599
+ }
4600
+ const conversations = await inspector.listConversations(inspectorOptions);
4601
+ return conversations.map((conversation) => sourceConversationSummary(conversation, summary.agentIds)).filter(
4602
+ (conversation) => options.userId === void 0 || conversation.userId === options.userId
4603
+ ).slice(0, options.limit);
4604
+ },
4605
+ async getConversation(conversationRef) {
4606
+ const conversation = await inspector.getConversation(conversationRef);
4607
+ return conversation === void 0 ? void 0 : inspectorConversationDetail(conversation, summary.agentIds);
4608
+ }
4609
+ };
4610
+ }
4611
+ function unavailableAgentSource(ref, label, agentId, storeKindValue) {
4612
+ const summary = {
4613
+ ref,
4614
+ kind: "agent",
4615
+ label,
4616
+ agentIds: [agentId],
4617
+ available: false,
4618
+ reason: "This memory store does not expose the optional inspector capability."
4619
+ };
4620
+ if (storeKindValue !== void 0) summary.storeKind = storeKindValue;
4621
+ return {
4622
+ summary,
4623
+ listConversations: async () => [],
4624
+ getConversation: async () => void 0
4625
+ };
4626
+ }
4627
+ function studioSessionSource(sessionStore, agentIds) {
4628
+ const summary = {
4629
+ ref: "studio-sessions",
4630
+ kind: "studio",
4631
+ label: "Studio sessions",
4632
+ agentIds: [...agentIds],
4633
+ available: true,
4634
+ storeKind: sessionStore.kind ?? "studio"
4635
+ };
4636
+ const allowedAgents = new Set(agentIds);
4637
+ const restrictAgents = allowedAgents.size > 0;
4638
+ return {
4639
+ summary,
4640
+ async listConversations(options) {
4641
+ const sessions = await sessionStore.listSessions({ limit: USER_DISCOVERY_LIMIT });
4642
+ return sessions.filter((session) => !restrictAgents || allowedAgents.has(session.agentId)).map(studioSourceConversationSummary).filter(
4643
+ (conversation) => options.userId === void 0 || conversation.userId === options.userId
4644
+ ).slice(0, options.limit);
4645
+ },
4646
+ async getConversation(conversationRef) {
4647
+ const session = await sessionStore.getSession(conversationRef);
4648
+ if (session === void 0 || restrictAgents && !allowedAgents.has(session.agentId)) {
4649
+ return void 0;
4650
+ }
4651
+ return {
4652
+ conversation: studioSourceConversationSummary(session),
4653
+ records: session.messages.map((message, position) => ({
4654
+ position,
4655
+ runId: "studio-session",
4656
+ turn: 0,
4657
+ createdAt: session.updatedAt,
4658
+ message
4659
+ }))
4660
+ };
4661
+ }
4662
+ };
4663
+ }
4664
+ function sourceConversationSummary(conversation, agentIds) {
4665
+ const summary = {
4666
+ ref: conversation.ref,
4667
+ sessionId: conversation.sessionId,
4668
+ userId: conversation.userId ?? DEFAULT_USER_ID,
4669
+ agentIds: [...agentIds],
4670
+ createdAt: conversation.createdAt,
4671
+ updatedAt: conversation.updatedAt,
4672
+ messageCount: conversation.messageCount
4673
+ };
4674
+ if (conversation.metadata !== void 0) summary.metadata = conversation.metadata;
4675
+ return summary;
4676
+ }
4677
+ function inspectorConversationDetail(conversation, agentIds) {
4678
+ return {
4679
+ conversation: sourceConversationSummary(conversation, agentIds),
4680
+ records: conversation.messages
4681
+ };
4682
+ }
4683
+ function studioSourceConversationSummary(session) {
4684
+ const summary = {
4685
+ ref: session.id,
4686
+ sessionId: session.id,
4687
+ userId: sessionUserId(session),
4688
+ agentIds: [session.agentId],
4689
+ createdAt: session.createdAt,
4690
+ updatedAt: session.updatedAt,
4691
+ messageCount: session.messageCount
4692
+ };
4693
+ if (session.title !== void 0) summary.title = session.title;
4694
+ if (session.metadata !== void 0) summary.metadata = session.metadata;
4695
+ return summary;
4696
+ }
4697
+ function memoryUsers(conversations, limit) {
4698
+ const users = /* @__PURE__ */ new Map();
4699
+ for (const conversation of conversations) {
4700
+ const existing = users.get(conversation.userId);
4701
+ if (existing === void 0) {
4702
+ users.set(conversation.userId, {
4703
+ userId: conversation.userId,
4704
+ conversationCount: 1,
4705
+ agentIds: [...conversation.agentIds],
4706
+ lastInteractionAt: conversation.updatedAt
4707
+ });
4708
+ continue;
4709
+ }
4710
+ existing.conversationCount += 1;
4711
+ for (const agentId of conversation.agentIds) {
4712
+ if (!existing.agentIds.includes(agentId)) existing.agentIds.push(agentId);
4713
+ }
4714
+ if (new Date(conversation.updatedAt).getTime() > new Date(existing.lastInteractionAt).getTime()) {
4715
+ existing.lastInteractionAt = conversation.updatedAt;
4716
+ }
4717
+ }
4718
+ return {
4719
+ users: [...users.values()].sort(
4720
+ (left, right) => new Date(right.lastInteractionAt).getTime() - new Date(left.lastInteractionAt).getTime()
4721
+ ).slice(0, limit),
4722
+ total: users.size
4723
+ };
4724
+ }
4458
4725
  function memoryConversationSummary(session) {
4459
4726
  const summary = {
4460
4727
  id: session.id,
@@ -4472,6 +4739,19 @@ function sessionUserId(session) {
4472
4739
  const userId = session.metadata?.userId;
4473
4740
  return typeof userId === "string" && userId.trim().length > 0 ? userId : DEFAULT_USER_ID;
4474
4741
  }
4742
+ function storeKind(store) {
4743
+ const kind = store.kind;
4744
+ return typeof kind === "string" && kind.length > 0 ? kind : void 0;
4745
+ }
4746
+ function unavailableSourceResponse(c, source) {
4747
+ return errorResponse(
4748
+ c,
4749
+ 501,
4750
+ "unsupported_capability",
4751
+ source.reason ?? "Memory source is not inspectable",
4752
+ { sourceRef: source.ref }
4753
+ );
4754
+ }
4475
4755
 
4476
4756
  // src/runtime/pipeline-logs.ts
4477
4757
  async function appendPipelineLog(store, input) {
@@ -6609,6 +6889,7 @@ function createStudioApp(options) {
6609
6889
  const approvalRuntime = createApprovalRuntime();
6610
6890
  const questionRuntime = createQuestionRuntime();
6611
6891
  const sandboxRegistry = createStudioSandboxRegistry(agents);
6892
+ const memorySources = createStudioMemorySourceRegistry(agents, stores.sessions);
6612
6893
  const app = new HonoApp();
6613
6894
  const uiOptions = isStudioUiEnabled(options.ui) ? resolveStudioUiOptions(options.ui) : void 0;
6614
6895
  if (uiOptions !== void 0 && !uiOptions.protectShell) {
@@ -6682,10 +6963,13 @@ function createStudioApp(options) {
6682
6963
  approvalRuntime,
6683
6964
  questionRuntime
6684
6965
  });
6685
- if (stores.sessions !== void 0) {
6966
+ if (memorySources.size > 0 || stores.sessions !== void 0) {
6686
6967
  registerMemoryRoutes(app, {
6968
+ sources: memorySources,
6687
6969
  sessionStore: stores.sessions
6688
6970
  });
6971
+ }
6972
+ if (stores.sessions !== void 0) {
6689
6973
  const sessionOptions = {
6690
6974
  agentMap,
6691
6975
  sessionStore: stores.sessions