@anvia/studio 0.7.34 → 0.7.36
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/index.d.ts +54 -1
- package/dist/index.js +293 -8
- package/dist/index.js.map +1 -1
- package/dist/ui/assets/{PathIcon-DX1w_Nk9.js → PathIcon-B7p7vF2d.js} +1 -1
- package/dist/ui/assets/{PathIcon-DX1w_Nk9.js.map → PathIcon-B7p7vF2d.js.map} +1 -1
- package/dist/ui/assets/{PlayIcon-Culan3xL.js → PlayIcon-Dt2gGfiW.js} +1 -1
- package/dist/ui/assets/{PlayIcon-Culan3xL.js.map → PlayIcon-Dt2gGfiW.js.map} +1 -1
- package/dist/ui/assets/{RefreshIcon-B3w42HZJ.js → RefreshIcon-BOrxG7tt.js} +1 -1
- package/dist/ui/assets/{RefreshIcon-B3w42HZJ.js.map → RefreshIcon-BOrxG7tt.js.map} +1 -1
- package/dist/ui/assets/{agents-page-nyn87qWN.js → agents-page-BdDnlVyJ.js} +2 -2
- package/dist/ui/assets/{agents-page-nyn87qWN.js.map → agents-page-BdDnlVyJ.js.map} +1 -1
- package/dist/ui/assets/{badge-BH7gz3tB.js → badge-CeTBFuRX.js} +1 -1
- package/dist/ui/assets/{badge-BH7gz3tB.js.map → badge-CeTBFuRX.js.map} +1 -1
- package/dist/ui/assets/chunk-FE5QL4G3-C1KRmMy_.js +2 -0
- package/dist/ui/assets/chunk-FE5QL4G3-C1KRmMy_.js.map +1 -0
- package/dist/ui/assets/{evals-page-CHxft1PA.js → evals-page-1QJywSGG.js} +2 -2
- package/dist/ui/assets/{evals-page-CHxft1PA.js.map → evals-page-1QJywSGG.js.map} +1 -1
- package/dist/ui/assets/index-BncPUHdf.css +1 -0
- package/dist/ui/assets/index-DsFqmLt-.js +55 -0
- package/dist/ui/assets/index-DsFqmLt-.js.map +1 -0
- package/dist/ui/assets/{knowledge-page-BIphUowG.js → knowledge-page-Bh0HYSnR.js} +2 -2
- package/dist/ui/assets/{knowledge-page-BIphUowG.js.map → knowledge-page-Bh0HYSnR.js.map} +1 -1
- package/dist/ui/assets/{mcps-page-CEyvZfpe.js → mcps-page-BoMVJjHL.js} +2 -2
- package/dist/ui/assets/{mcps-page-CEyvZfpe.js.map → mcps-page-BoMVJjHL.js.map} +1 -1
- package/dist/ui/assets/memory-page-B-LtyVhA.js +4 -0
- package/dist/ui/assets/memory-page-B-LtyVhA.js.map +1 -0
- package/dist/ui/assets/{pipelines-page-BllEnKpu.js → pipelines-page-DeIlIHCP.js} +2 -2
- package/dist/ui/assets/{pipelines-page-BllEnKpu.js.map → pipelines-page-DeIlIHCP.js.map} +1 -1
- package/dist/ui/assets/{renderers-Dzjh-nGh.js → renderers-IW2ZAJZw.js} +1 -1
- package/dist/ui/assets/{renderers-Dzjh-nGh.js.map → renderers-IW2ZAJZw.js.map} +1 -1
- package/dist/ui/assets/{sandboxes-page-B8GcUS5f.js → sandboxes-page-B_Lf-UtP.js} +2 -2
- package/dist/ui/assets/{sandboxes-page-B8GcUS5f.js.map → sandboxes-page-B_Lf-UtP.js.map} +1 -1
- package/dist/ui/assets/{sessions-page-BY2ysr2u.js → sessions-page-DjAuU-RX.js} +2 -2
- package/dist/ui/assets/{sessions-page-BY2ysr2u.js.map → sessions-page-DjAuU-RX.js.map} +1 -1
- package/dist/ui/assets/{status-page-CZ0HBJY5.js → status-page-BaDIKvef.js} +2 -2
- package/dist/ui/assets/{status-page-CZ0HBJY5.js.map → status-page-BaDIKvef.js.map} +1 -1
- package/dist/ui/assets/{tool-runner-CkQ3WBw4.js → tool-runner-C5vzRzrt.js} +2 -2
- package/dist/ui/assets/{tool-runner-CkQ3WBw4.js.map → tool-runner-C5vzRzrt.js.map} +1 -1
- package/dist/ui/assets/{tools-page-CmVAorUe.js → tools-page-ClNVTM2F.js} +2 -2
- package/dist/ui/assets/{tools-page-CmVAorUe.js.map → tools-page-ClNVTM2F.js.map} +1 -1
- package/dist/ui/assets/{trace-browser-DekV4BNP.js → trace-browser-BQ_YWG4y.js} +2 -2
- package/dist/ui/assets/{trace-browser-DekV4BNP.js.map → trace-browser-BQ_YWG4y.js.map} +1 -1
- package/dist/ui/assets/{transcript-item-CQCD2CY3.js → transcript-item-CdsVcgad.js} +2 -2
- package/dist/ui/assets/{transcript-item-CQCD2CY3.js.map → transcript-item-CdsVcgad.js.map} +1 -1
- package/dist/ui/index.html +3 -2
- package/package.json +5 -5
- package/dist/ui/assets/index-DMB9ju7U.css +0 -1
- package/dist/ui/assets/index-DgQb2APn.js +0 -55
- package/dist/ui/assets/index-DgQb2APn.js.map +0 -1
- package/dist/ui/assets/memory-page-C2Nph26O.js +0 -2
- 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
|
@@ -3193,6 +3193,7 @@ function createRunRequest(props) {
|
|
|
3193
3193
|
const request = props.session !== void 0 ? props.runAgent.memory === void 0 ? props.runAgent.prompt([...props.session.messages, props.promptMessage]) : props.runAgent.session(props.session.id, { metadata: props.memoryMetadata }).prompt(props.body.message) : props.runAgent.prompt(
|
|
3194
3194
|
props.body.history !== void 0 ? [...props.body.history, props.promptMessage] : props.body.message
|
|
3195
3195
|
);
|
|
3196
|
+
request.withCompletionRetries();
|
|
3196
3197
|
if (props.body.maxTurns !== void 0) {
|
|
3197
3198
|
request.maxTurns(props.body.maxTurns);
|
|
3198
3199
|
}
|
|
@@ -3830,6 +3831,8 @@ function capabilityConfig(_options, agents, pipelines, stores, sandboxCount = 0)
|
|
|
3830
3831
|
};
|
|
3831
3832
|
if (stores.sessions !== void 0) {
|
|
3832
3833
|
capabilities.sessions = { enabled: true };
|
|
3834
|
+
}
|
|
3835
|
+
if (stores.sessions !== void 0 || agents.some((agent) => agent.agent.memory !== void 0)) {
|
|
3833
3836
|
capabilities.memory = { enabled: true };
|
|
3834
3837
|
}
|
|
3835
3838
|
if (stores.traces !== void 0) {
|
|
@@ -4384,13 +4387,137 @@ async function agentMcpMetadata(agent) {
|
|
|
4384
4387
|
|
|
4385
4388
|
// src/runtime/memory.ts
|
|
4386
4389
|
var DEFAULT_USER_ID = "default";
|
|
4390
|
+
var USER_DISCOVERY_LIMIT = 1e3;
|
|
4391
|
+
function createStudioMemorySourceRegistry(agents, sessionStore) {
|
|
4392
|
+
const sources = [];
|
|
4393
|
+
const byStore = /* @__PURE__ */ new Map();
|
|
4394
|
+
const agentsWithoutMemory = [];
|
|
4395
|
+
for (const agent of agents) {
|
|
4396
|
+
const store = agent.agent.memory?.store;
|
|
4397
|
+
if (store === void 0) {
|
|
4398
|
+
agentsWithoutMemory.push(agent);
|
|
4399
|
+
continue;
|
|
4400
|
+
}
|
|
4401
|
+
const existing = byStore.get(store);
|
|
4402
|
+
if (existing !== void 0) {
|
|
4403
|
+
existing.summary.agentIds.push(agent.id);
|
|
4404
|
+
existing.summary.label = "Shared agent memory";
|
|
4405
|
+
continue;
|
|
4406
|
+
}
|
|
4407
|
+
const ref = `agent-memory-${sources.length + 1}`;
|
|
4408
|
+
const label = `${agent.name ?? agent.agent.name ?? agent.id} memory`;
|
|
4409
|
+
const kind = storeKind(store);
|
|
4410
|
+
const source = store.inspector === void 0 ? unavailableAgentSource(ref, label, agent.id, kind) : agentMemorySource(ref, label, agent.id, kind, store.inspector);
|
|
4411
|
+
sources.push(source);
|
|
4412
|
+
byStore.set(store, source);
|
|
4413
|
+
}
|
|
4414
|
+
if (sessionStore !== void 0 && (agentsWithoutMemory.length > 0 || agents.length === 0)) {
|
|
4415
|
+
sources.push(
|
|
4416
|
+
studioSessionSource(
|
|
4417
|
+
sessionStore,
|
|
4418
|
+
agentsWithoutMemory.map((agent) => agent.id)
|
|
4419
|
+
)
|
|
4420
|
+
);
|
|
4421
|
+
}
|
|
4422
|
+
const byRef = new Map(sources.map((source) => [source.summary.ref, source]));
|
|
4423
|
+
return {
|
|
4424
|
+
size: sources.length,
|
|
4425
|
+
list: () => sources.map((source) => ({ ...source.summary, agentIds: [...source.summary.agentIds] })),
|
|
4426
|
+
get: (ref) => byRef.get(ref)
|
|
4427
|
+
};
|
|
4428
|
+
}
|
|
4387
4429
|
function registerMemoryRoutes(app, props) {
|
|
4430
|
+
registerMemorySourceRoutes(app, props.sources);
|
|
4431
|
+
if (props.sessionStore !== void 0) {
|
|
4432
|
+
registerLegacyMemoryRoutes(app, props.sessionStore);
|
|
4433
|
+
}
|
|
4434
|
+
}
|
|
4435
|
+
function registerMemorySourceRoutes(app, registry) {
|
|
4436
|
+
app.get(
|
|
4437
|
+
"/memory/sources",
|
|
4438
|
+
(c) => c.json({ sources: registry.list() })
|
|
4439
|
+
);
|
|
4440
|
+
app.get("/memory/sources/:sourceRef/users", async (c) => {
|
|
4441
|
+
const limit = parseLimit(c.req.query("limit"));
|
|
4442
|
+
if (limit === void 0) {
|
|
4443
|
+
return errorResponse(c, 400, "bad_request", "limit must be a positive integer");
|
|
4444
|
+
}
|
|
4445
|
+
const source = registry.get(c.req.param("sourceRef"));
|
|
4446
|
+
if (source === void 0) {
|
|
4447
|
+
return errorResponse(c, 404, "not_found", "Memory source not found");
|
|
4448
|
+
}
|
|
4449
|
+
if (!source.summary.available) return unavailableSourceResponse(c, source.summary);
|
|
4450
|
+
const conversations = await source.listConversations({ limit: USER_DISCOVERY_LIMIT });
|
|
4451
|
+
const userPage = memoryUsers(conversations, limit);
|
|
4452
|
+
return c.json({
|
|
4453
|
+
source: source.summary,
|
|
4454
|
+
users: userPage.users,
|
|
4455
|
+
total: userPage.total
|
|
4456
|
+
});
|
|
4457
|
+
});
|
|
4458
|
+
app.get("/memory/sources/:sourceRef/conversations", async (c) => {
|
|
4459
|
+
const limit = parseLimit(c.req.query("limit"));
|
|
4460
|
+
if (limit === void 0) {
|
|
4461
|
+
return errorResponse(c, 400, "bad_request", "limit must be a positive integer");
|
|
4462
|
+
}
|
|
4463
|
+
const source = registry.get(c.req.param("sourceRef"));
|
|
4464
|
+
if (source === void 0) {
|
|
4465
|
+
return errorResponse(c, 404, "not_found", "Memory source not found");
|
|
4466
|
+
}
|
|
4467
|
+
if (!source.summary.available) return unavailableSourceResponse(c, source.summary);
|
|
4468
|
+
const userId = optionalQueryString(c.req.query("userId"));
|
|
4469
|
+
const listOptions = { limit };
|
|
4470
|
+
if (userId !== void 0) listOptions.userId = userId;
|
|
4471
|
+
const conversations = await source.listConversations(listOptions);
|
|
4472
|
+
return c.json({
|
|
4473
|
+
source: source.summary,
|
|
4474
|
+
conversations,
|
|
4475
|
+
total: conversations.length
|
|
4476
|
+
});
|
|
4477
|
+
});
|
|
4478
|
+
app.get("/memory/sources/:sourceRef/conversations/:conversationRef/messages", async (c) => {
|
|
4479
|
+
const source = registry.get(c.req.param("sourceRef"));
|
|
4480
|
+
if (source === void 0) {
|
|
4481
|
+
return errorResponse(c, 404, "not_found", "Memory source not found");
|
|
4482
|
+
}
|
|
4483
|
+
if (!source.summary.available) return unavailableSourceResponse(c, source.summary);
|
|
4484
|
+
const detail = await source.getConversation(c.req.param("conversationRef"));
|
|
4485
|
+
if (detail === void 0) {
|
|
4486
|
+
return errorResponse(c, 404, "not_found", "Conversation not found");
|
|
4487
|
+
}
|
|
4488
|
+
const messages = detail.records.map((record) => record.message);
|
|
4489
|
+
return c.json({
|
|
4490
|
+
source: source.summary,
|
|
4491
|
+
conversation: detail.conversation,
|
|
4492
|
+
messages,
|
|
4493
|
+
records: detail.records,
|
|
4494
|
+
transcript: transcriptFromMessages(messages)
|
|
4495
|
+
});
|
|
4496
|
+
});
|
|
4497
|
+
app.get("/memory/sources/:sourceRef/conversations/:conversationRef/steps", async (c) => {
|
|
4498
|
+
const source = registry.get(c.req.param("sourceRef"));
|
|
4499
|
+
if (source === void 0) {
|
|
4500
|
+
return errorResponse(c, 404, "not_found", "Memory source not found");
|
|
4501
|
+
}
|
|
4502
|
+
if (!source.summary.available) return unavailableSourceResponse(c, source.summary);
|
|
4503
|
+
const detail = await source.getConversation(c.req.param("conversationRef"));
|
|
4504
|
+
if (detail === void 0) {
|
|
4505
|
+
return errorResponse(c, 404, "not_found", "Conversation not found");
|
|
4506
|
+
}
|
|
4507
|
+
return c.json({
|
|
4508
|
+
source: source.summary,
|
|
4509
|
+
conversation: detail.conversation,
|
|
4510
|
+
steps: transcriptFromMessages(detail.records.map((record) => record.message))
|
|
4511
|
+
});
|
|
4512
|
+
});
|
|
4513
|
+
}
|
|
4514
|
+
function registerLegacyMemoryRoutes(app, sessionStore) {
|
|
4388
4515
|
app.get("/memory/users", async (c) => {
|
|
4389
4516
|
const limit = parseLimit(c.req.query("limit"));
|
|
4390
4517
|
if (limit === void 0) {
|
|
4391
4518
|
return errorResponse(c, 400, "bad_request", "limit must be a positive integer");
|
|
4392
4519
|
}
|
|
4393
|
-
const sessions = await
|
|
4520
|
+
const sessions = await sessionStore.listSessions({ limit: 100 });
|
|
4394
4521
|
const users = /* @__PURE__ */ new Map();
|
|
4395
4522
|
for (const session of sessions) {
|
|
4396
4523
|
const userId = sessionUserId(session);
|
|
@@ -4405,9 +4532,7 @@ function registerMemoryRoutes(app, props) {
|
|
|
4405
4532
|
continue;
|
|
4406
4533
|
}
|
|
4407
4534
|
existing.conversationCount += 1;
|
|
4408
|
-
if (!existing.agentIds.includes(session.agentId))
|
|
4409
|
-
existing.agentIds.push(session.agentId);
|
|
4410
|
-
}
|
|
4535
|
+
if (!existing.agentIds.includes(session.agentId)) existing.agentIds.push(session.agentId);
|
|
4411
4536
|
if (new Date(session.updatedAt).getTime() > new Date(existing.lastInteractionAt).getTime()) {
|
|
4412
4537
|
existing.lastInteractionAt = session.updatedAt;
|
|
4413
4538
|
}
|
|
@@ -4426,7 +4551,7 @@ function registerMemoryRoutes(app, props) {
|
|
|
4426
4551
|
const userId = optionalQueryString(c.req.query("userId"));
|
|
4427
4552
|
const listInput = { limit: 100 };
|
|
4428
4553
|
if (agentId !== void 0) listInput.agentId = agentId;
|
|
4429
|
-
const sessions = await
|
|
4554
|
+
const sessions = await sessionStore.listSessions(listInput);
|
|
4430
4555
|
const conversations = sessions.map(memoryConversationSummary).filter((session) => userId === void 0 || session.userId === userId).slice(0, limit);
|
|
4431
4556
|
return c.json({
|
|
4432
4557
|
conversations,
|
|
@@ -4434,7 +4559,7 @@ function registerMemoryRoutes(app, props) {
|
|
|
4434
4559
|
});
|
|
4435
4560
|
});
|
|
4436
4561
|
app.get("/memory/conversations/:conversationId/messages", async (c) => {
|
|
4437
|
-
const session = await
|
|
4562
|
+
const session = await sessionStore.getSession(c.req.param("conversationId"));
|
|
4438
4563
|
if (session === void 0) {
|
|
4439
4564
|
return errorResponse(c, 404, "not_found", "Conversation not found");
|
|
4440
4565
|
}
|
|
@@ -4445,7 +4570,7 @@ function registerMemoryRoutes(app, props) {
|
|
|
4445
4570
|
});
|
|
4446
4571
|
});
|
|
4447
4572
|
app.get("/memory/conversations/:conversationId/steps", async (c) => {
|
|
4448
|
-
const session = await
|
|
4573
|
+
const session = await sessionStore.getSession(c.req.param("conversationId"));
|
|
4449
4574
|
if (session === void 0) {
|
|
4450
4575
|
return errorResponse(c, 404, "not_found", "Conversation not found");
|
|
4451
4576
|
}
|
|
@@ -4455,6 +4580,149 @@ function registerMemoryRoutes(app, props) {
|
|
|
4455
4580
|
});
|
|
4456
4581
|
});
|
|
4457
4582
|
}
|
|
4583
|
+
function agentMemorySource(ref, label, agentId, storeKindValue, inspector) {
|
|
4584
|
+
const summary = {
|
|
4585
|
+
ref,
|
|
4586
|
+
kind: "agent",
|
|
4587
|
+
label,
|
|
4588
|
+
agentIds: [agentId],
|
|
4589
|
+
available: true
|
|
4590
|
+
};
|
|
4591
|
+
if (storeKindValue !== void 0) summary.storeKind = storeKindValue;
|
|
4592
|
+
return {
|
|
4593
|
+
summary,
|
|
4594
|
+
async listConversations(options) {
|
|
4595
|
+
const inspectorOptions = {
|
|
4596
|
+
limit: options.userId === DEFAULT_USER_ID ? USER_DISCOVERY_LIMIT : options.limit
|
|
4597
|
+
};
|
|
4598
|
+
if (options.userId !== void 0 && options.userId !== DEFAULT_USER_ID) {
|
|
4599
|
+
inspectorOptions.userId = options.userId;
|
|
4600
|
+
}
|
|
4601
|
+
const conversations = await inspector.listConversations(inspectorOptions);
|
|
4602
|
+
return conversations.map((conversation) => sourceConversationSummary(conversation, summary.agentIds)).filter(
|
|
4603
|
+
(conversation) => options.userId === void 0 || conversation.userId === options.userId
|
|
4604
|
+
).slice(0, options.limit);
|
|
4605
|
+
},
|
|
4606
|
+
async getConversation(conversationRef) {
|
|
4607
|
+
const conversation = await inspector.getConversation(conversationRef);
|
|
4608
|
+
return conversation === void 0 ? void 0 : inspectorConversationDetail(conversation, summary.agentIds);
|
|
4609
|
+
}
|
|
4610
|
+
};
|
|
4611
|
+
}
|
|
4612
|
+
function unavailableAgentSource(ref, label, agentId, storeKindValue) {
|
|
4613
|
+
const summary = {
|
|
4614
|
+
ref,
|
|
4615
|
+
kind: "agent",
|
|
4616
|
+
label,
|
|
4617
|
+
agentIds: [agentId],
|
|
4618
|
+
available: false,
|
|
4619
|
+
reason: "This memory store does not expose the optional inspector capability."
|
|
4620
|
+
};
|
|
4621
|
+
if (storeKindValue !== void 0) summary.storeKind = storeKindValue;
|
|
4622
|
+
return {
|
|
4623
|
+
summary,
|
|
4624
|
+
listConversations: async () => [],
|
|
4625
|
+
getConversation: async () => void 0
|
|
4626
|
+
};
|
|
4627
|
+
}
|
|
4628
|
+
function studioSessionSource(sessionStore, agentIds) {
|
|
4629
|
+
const summary = {
|
|
4630
|
+
ref: "studio-sessions",
|
|
4631
|
+
kind: "studio",
|
|
4632
|
+
label: "Studio sessions",
|
|
4633
|
+
agentIds: [...agentIds],
|
|
4634
|
+
available: true,
|
|
4635
|
+
storeKind: sessionStore.kind ?? "studio"
|
|
4636
|
+
};
|
|
4637
|
+
const allowedAgents = new Set(agentIds);
|
|
4638
|
+
const restrictAgents = allowedAgents.size > 0;
|
|
4639
|
+
return {
|
|
4640
|
+
summary,
|
|
4641
|
+
async listConversations(options) {
|
|
4642
|
+
const sessions = await sessionStore.listSessions({ limit: USER_DISCOVERY_LIMIT });
|
|
4643
|
+
return sessions.filter((session) => !restrictAgents || allowedAgents.has(session.agentId)).map(studioSourceConversationSummary).filter(
|
|
4644
|
+
(conversation) => options.userId === void 0 || conversation.userId === options.userId
|
|
4645
|
+
).slice(0, options.limit);
|
|
4646
|
+
},
|
|
4647
|
+
async getConversation(conversationRef) {
|
|
4648
|
+
const session = await sessionStore.getSession(conversationRef);
|
|
4649
|
+
if (session === void 0 || restrictAgents && !allowedAgents.has(session.agentId)) {
|
|
4650
|
+
return void 0;
|
|
4651
|
+
}
|
|
4652
|
+
return {
|
|
4653
|
+
conversation: studioSourceConversationSummary(session),
|
|
4654
|
+
records: session.messages.map((message, position) => ({
|
|
4655
|
+
position,
|
|
4656
|
+
runId: "studio-session",
|
|
4657
|
+
turn: 0,
|
|
4658
|
+
createdAt: session.updatedAt,
|
|
4659
|
+
message
|
|
4660
|
+
}))
|
|
4661
|
+
};
|
|
4662
|
+
}
|
|
4663
|
+
};
|
|
4664
|
+
}
|
|
4665
|
+
function sourceConversationSummary(conversation, agentIds) {
|
|
4666
|
+
const summary = {
|
|
4667
|
+
ref: conversation.ref,
|
|
4668
|
+
sessionId: conversation.sessionId,
|
|
4669
|
+
userId: conversation.userId ?? DEFAULT_USER_ID,
|
|
4670
|
+
agentIds: [...agentIds],
|
|
4671
|
+
createdAt: conversation.createdAt,
|
|
4672
|
+
updatedAt: conversation.updatedAt,
|
|
4673
|
+
messageCount: conversation.messageCount
|
|
4674
|
+
};
|
|
4675
|
+
if (conversation.metadata !== void 0) summary.metadata = conversation.metadata;
|
|
4676
|
+
return summary;
|
|
4677
|
+
}
|
|
4678
|
+
function inspectorConversationDetail(conversation, agentIds) {
|
|
4679
|
+
return {
|
|
4680
|
+
conversation: sourceConversationSummary(conversation, agentIds),
|
|
4681
|
+
records: conversation.messages
|
|
4682
|
+
};
|
|
4683
|
+
}
|
|
4684
|
+
function studioSourceConversationSummary(session) {
|
|
4685
|
+
const summary = {
|
|
4686
|
+
ref: session.id,
|
|
4687
|
+
sessionId: session.id,
|
|
4688
|
+
userId: sessionUserId(session),
|
|
4689
|
+
agentIds: [session.agentId],
|
|
4690
|
+
createdAt: session.createdAt,
|
|
4691
|
+
updatedAt: session.updatedAt,
|
|
4692
|
+
messageCount: session.messageCount
|
|
4693
|
+
};
|
|
4694
|
+
if (session.title !== void 0) summary.title = session.title;
|
|
4695
|
+
if (session.metadata !== void 0) summary.metadata = session.metadata;
|
|
4696
|
+
return summary;
|
|
4697
|
+
}
|
|
4698
|
+
function memoryUsers(conversations, limit) {
|
|
4699
|
+
const users = /* @__PURE__ */ new Map();
|
|
4700
|
+
for (const conversation of conversations) {
|
|
4701
|
+
const existing = users.get(conversation.userId);
|
|
4702
|
+
if (existing === void 0) {
|
|
4703
|
+
users.set(conversation.userId, {
|
|
4704
|
+
userId: conversation.userId,
|
|
4705
|
+
conversationCount: 1,
|
|
4706
|
+
agentIds: [...conversation.agentIds],
|
|
4707
|
+
lastInteractionAt: conversation.updatedAt
|
|
4708
|
+
});
|
|
4709
|
+
continue;
|
|
4710
|
+
}
|
|
4711
|
+
existing.conversationCount += 1;
|
|
4712
|
+
for (const agentId of conversation.agentIds) {
|
|
4713
|
+
if (!existing.agentIds.includes(agentId)) existing.agentIds.push(agentId);
|
|
4714
|
+
}
|
|
4715
|
+
if (new Date(conversation.updatedAt).getTime() > new Date(existing.lastInteractionAt).getTime()) {
|
|
4716
|
+
existing.lastInteractionAt = conversation.updatedAt;
|
|
4717
|
+
}
|
|
4718
|
+
}
|
|
4719
|
+
return {
|
|
4720
|
+
users: [...users.values()].sort(
|
|
4721
|
+
(left, right) => new Date(right.lastInteractionAt).getTime() - new Date(left.lastInteractionAt).getTime()
|
|
4722
|
+
).slice(0, limit),
|
|
4723
|
+
total: users.size
|
|
4724
|
+
};
|
|
4725
|
+
}
|
|
4458
4726
|
function memoryConversationSummary(session) {
|
|
4459
4727
|
const summary = {
|
|
4460
4728
|
id: session.id,
|
|
@@ -4472,6 +4740,19 @@ function sessionUserId(session) {
|
|
|
4472
4740
|
const userId = session.metadata?.userId;
|
|
4473
4741
|
return typeof userId === "string" && userId.trim().length > 0 ? userId : DEFAULT_USER_ID;
|
|
4474
4742
|
}
|
|
4743
|
+
function storeKind(store) {
|
|
4744
|
+
const kind = store.kind;
|
|
4745
|
+
return typeof kind === "string" && kind.length > 0 ? kind : void 0;
|
|
4746
|
+
}
|
|
4747
|
+
function unavailableSourceResponse(c, source) {
|
|
4748
|
+
return errorResponse(
|
|
4749
|
+
c,
|
|
4750
|
+
501,
|
|
4751
|
+
"unsupported_capability",
|
|
4752
|
+
source.reason ?? "Memory source is not inspectable",
|
|
4753
|
+
{ sourceRef: source.ref }
|
|
4754
|
+
);
|
|
4755
|
+
}
|
|
4475
4756
|
|
|
4476
4757
|
// src/runtime/pipeline-logs.ts
|
|
4477
4758
|
async function appendPipelineLog(store, input) {
|
|
@@ -6609,6 +6890,7 @@ function createStudioApp(options) {
|
|
|
6609
6890
|
const approvalRuntime = createApprovalRuntime();
|
|
6610
6891
|
const questionRuntime = createQuestionRuntime();
|
|
6611
6892
|
const sandboxRegistry = createStudioSandboxRegistry(agents);
|
|
6893
|
+
const memorySources = createStudioMemorySourceRegistry(agents, stores.sessions);
|
|
6612
6894
|
const app = new HonoApp();
|
|
6613
6895
|
const uiOptions = isStudioUiEnabled(options.ui) ? resolveStudioUiOptions(options.ui) : void 0;
|
|
6614
6896
|
if (uiOptions !== void 0 && !uiOptions.protectShell) {
|
|
@@ -6682,10 +6964,13 @@ function createStudioApp(options) {
|
|
|
6682
6964
|
approvalRuntime,
|
|
6683
6965
|
questionRuntime
|
|
6684
6966
|
});
|
|
6685
|
-
if (stores.sessions !== void 0) {
|
|
6967
|
+
if (memorySources.size > 0 || stores.sessions !== void 0) {
|
|
6686
6968
|
registerMemoryRoutes(app, {
|
|
6969
|
+
sources: memorySources,
|
|
6687
6970
|
sessionStore: stores.sessions
|
|
6688
6971
|
});
|
|
6972
|
+
}
|
|
6973
|
+
if (stores.sessions !== void 0) {
|
|
6689
6974
|
const sessionOptions = {
|
|
6690
6975
|
agentMap,
|
|
6691
6976
|
sessionStore: stores.sessions
|