@promptbook/cli 0.112.0-110 → 0.112.0-112
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/apps/agents-server/src/app/admin/servers/CreateServerDialog.tsx +16 -0
- package/apps/agents-server/src/app/admin/servers/useCreateServerWizard.ts +31 -5
- package/apps/agents-server/src/app/agents/[agentName]/_utils.ts +7 -5
- package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/[chatId]/stream/route.ts +4 -86
- package/apps/agents-server/src/app/api/admin/servers/route.ts +5 -0
- package/apps/agents-server/src/app/api/metadata/route.ts +4 -0
- package/apps/agents-server/src/components/ApplicationErrorPage/ApplicationErrorPage.tsx +118 -12
- package/apps/agents-server/src/database/customJavascript.ts +62 -1
- package/apps/agents-server/src/database/customStylesheet.ts +60 -1
- package/apps/agents-server/src/database/getMetadata.ts +84 -3
- package/apps/agents-server/src/instrumentation.ts +3 -0
- package/apps/agents-server/src/utils/agentRouting/resolveAgentRouteTarget.ts +27 -62
- package/apps/agents-server/src/utils/errorReporting/applicationErrorHandling.ts +45 -0
- package/apps/agents-server/src/utils/errorReporting/refreshApplicationDocument.ts +10 -0
- package/apps/agents-server/src/utils/errorReporting/registerServerErrorSentryLogging.ts +331 -0
- package/apps/agents-server/src/utils/errorReporting/sendApplicationErrorReportToSentry.ts +8 -153
- package/apps/agents-server/src/utils/errorReporting/sentryStore.ts +177 -0
- package/apps/agents-server/src/utils/importAgent.ts +1 -57
- package/apps/agents-server/src/utils/importAgentWithFallback.ts +0 -10
- package/apps/agents-server/src/utils/serverManagement/createManagedServer/bootstrapManagedServer.ts +3 -1
- package/apps/agents-server/src/utils/serverManagement/createManagedServer/normalizeCreateServerInput.ts +6 -0
- package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerDefaultAgents.ts +7 -3
- package/apps/agents-server/src/utils/serverManagement/createManagedServer.ts +5 -0
- package/apps/agents-server/src/utils/userChat/listUserChats.ts +109 -0
- package/apps/agents-server/src/utils/userChat.ts +0 -1
- package/esm/index.es.js +39 -13
- package/esm/index.es.js.map +1 -1
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +2 -1
- package/esm/src/cli/cli-commands/agents-server/startAgentsServer.test.d.ts +1 -0
- package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +22 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/cli/cli-commands/agents-server/startAgentsServer.ts +23 -2
- package/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.ts +91 -14
- package/src/other/templates/getTemplatesPipelineCollection.ts +801 -652
- package/src/version.ts +2 -2
- package/src/versions.txt +2 -0
- package/umd/index.umd.js +39 -13
- package/umd/index.umd.js.map +1 -1
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer.d.ts +2 -1
- package/umd/src/cli/cli-commands/agents-server/startAgentsServer.test.d.ts +1 -0
- package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +22 -0
- package/umd/src/version.d.ts +1 -1
- package/apps/agents-server/src/utils/userChat/getUserChatRevision.ts +0 -145
|
@@ -29,7 +29,8 @@ export type StartAgentsServerOptions = {
|
|
|
29
29
|
*/
|
|
30
30
|
export declare function startAgentsServer(options: StartAgentsServerOptions): Promise<void>;
|
|
31
31
|
/**
|
|
32
|
-
* Loads
|
|
32
|
+
* Loads Agents Server runtime environment from the installed `.env` file when explicitly configured and falls back
|
|
33
|
+
* to the launch-directory `.env`.
|
|
33
34
|
*
|
|
34
35
|
* @private internal utility of `ptbk agents-server`
|
|
35
36
|
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -60,6 +60,28 @@ export declare class AgentCollectionInSupabase {
|
|
|
60
60
|
* Gets all agents in the collection
|
|
61
61
|
*/
|
|
62
62
|
listAgents(): Promise<ReadonlyArray<AgentBasicInformation>>;
|
|
63
|
+
/**
|
|
64
|
+
* Finds one active agent profile by its human-readable name or permanent id.
|
|
65
|
+
*
|
|
66
|
+
* This keeps route-level lookups from loading the whole agent collection when only
|
|
67
|
+
* one canonical route identifier is needed.
|
|
68
|
+
*
|
|
69
|
+
* @param agentNameOrPermanentId - Agent name or stable permanent identifier.
|
|
70
|
+
* @returns Matching active agent profile or `null` when not found.
|
|
71
|
+
*
|
|
72
|
+
* @public exported from `@promptbook/core`
|
|
73
|
+
*/
|
|
74
|
+
findAgentBasicInformation(agentNameOrPermanentId: string_agent_name | string_agent_permanent_id): Promise<AgentBasicInformation | null>;
|
|
75
|
+
/**
|
|
76
|
+
* Converts one database row into public agent information.
|
|
77
|
+
*
|
|
78
|
+
* @param row - Database row carrying the persisted profile snapshot.
|
|
79
|
+
* @param isVerbose - Whether profile-name mismatches should be logged.
|
|
80
|
+
* @returns Agent profile with canonical database name and permanent id.
|
|
81
|
+
*
|
|
82
|
+
* @private internal helper of `AgentCollectionInSupabase`
|
|
83
|
+
*/
|
|
84
|
+
private mapAgentBasicInformationRow;
|
|
63
85
|
/**
|
|
64
86
|
* Retrieves the permanent ID of an agent by its name or permanent ID.
|
|
65
87
|
*/
|
package/umd/src/version.d.ts
CHANGED
|
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
|
|
|
15
15
|
export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
|
|
16
16
|
/**
|
|
17
17
|
* Represents the version string of the Promptbook engine.
|
|
18
|
-
* It follows semantic versioning (e.g., `0.112.0-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.112.0-111`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
|
@@ -1,145 +0,0 @@
|
|
|
1
|
-
import type { UserChatRow } from './UserChatRow';
|
|
2
|
-
import { provideUserChatTable } from './provideUserChatTable';
|
|
3
|
-
import type { UserChatJobRow } from './UserChatJobRow';
|
|
4
|
-
import { provideUserChatJobTable } from './provideUserChatJobTable';
|
|
5
|
-
import { ACTIVE_USER_CHAT_TIMEOUT_STATUSES } from '../userChatTimeout/userChatTimeoutStore/ACTIVE_USER_CHAT_TIMEOUT_STATUSES';
|
|
6
|
-
import { isMissingUserChatTimeoutRelationError } from '../userChatTimeout/userChatTimeoutStore/isMissingUserChatTimeoutRelationError';
|
|
7
|
-
import { provideUserChatTimeoutTable } from '../userChatTimeout/userChatTimeoutStore/provideUserChatTimeoutTable';
|
|
8
|
-
import type { UserChatTimeoutRow } from '../userChatTimeout/UserChatTimeoutRecord';
|
|
9
|
-
import { USER_CHAT_SOURCES } from './UserChatSource';
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Active user-chat job statuses that keep the live chat stream in a faster polling mode.
|
|
13
|
-
*/
|
|
14
|
-
const ACTIVE_USER_CHAT_JOB_STATUSES = ['QUEUED', 'RUNNING'] as const;
|
|
15
|
-
|
|
16
|
-
/**
|
|
17
|
-
* Compact active-job shape used only for revision comparison.
|
|
18
|
-
*/
|
|
19
|
-
export type UserChatRevisionJob = Pick<UserChatJobRow, 'id' | 'status' | 'cancelRequestedAt'>;
|
|
20
|
-
|
|
21
|
-
/**
|
|
22
|
-
* Compact active-timeout shape used only for revision comparison.
|
|
23
|
-
*/
|
|
24
|
-
export type UserChatRevisionTimeout = Pick<
|
|
25
|
-
UserChatTimeoutRow,
|
|
26
|
-
'id' | 'status' | 'message' | 'dueAt' | 'cancelRequestedAt'
|
|
27
|
-
>;
|
|
28
|
-
|
|
29
|
-
/**
|
|
30
|
-
* Lightweight revision metadata for detecting whether a chat detail payload changed.
|
|
31
|
-
*/
|
|
32
|
-
export type UserChatRevision = {
|
|
33
|
-
id: string;
|
|
34
|
-
updatedAt: string;
|
|
35
|
-
draftMessage: string | null;
|
|
36
|
-
source: UserChatRow['source'];
|
|
37
|
-
activeJobs: Array<UserChatRevisionJob>;
|
|
38
|
-
activeTimeouts: Array<UserChatRevisionTimeout>;
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
/**
|
|
42
|
-
* Loads one scoped chat revision without hydrating the full `messages` JSON payload.
|
|
43
|
-
*/
|
|
44
|
-
export async function getUserChatRevision(options: {
|
|
45
|
-
userId: number;
|
|
46
|
-
viewerIsAdmin?: boolean;
|
|
47
|
-
agentPermanentId: string;
|
|
48
|
-
chatId: string;
|
|
49
|
-
}): Promise<UserChatRevision | null> {
|
|
50
|
-
const { userId, viewerIsAdmin = false, agentPermanentId, chatId } = options;
|
|
51
|
-
const userChatTable = await provideUserChatTable();
|
|
52
|
-
|
|
53
|
-
const { data, error } = await userChatTable
|
|
54
|
-
.select('id, userId, updatedAt, draftMessage, source')
|
|
55
|
-
.eq('id', chatId)
|
|
56
|
-
.eq('agentPermanentId', agentPermanentId)
|
|
57
|
-
.maybeSingle();
|
|
58
|
-
|
|
59
|
-
if (error) {
|
|
60
|
-
throw new Error(`Failed to load user chat revision "${chatId}": ${error.message}`);
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
if (!data) {
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
const row = data as Pick<UserChatRow, 'id' | 'userId' | 'updatedAt' | 'draftMessage' | 'source'>;
|
|
68
|
-
if (row.source === USER_CHAT_SOURCES.WEB_UI) {
|
|
69
|
-
if (row.userId !== userId) {
|
|
70
|
-
return null;
|
|
71
|
-
}
|
|
72
|
-
} else if (!viewerIsAdmin) {
|
|
73
|
-
return null;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
const [activeJobs, activeTimeouts] = await Promise.all([
|
|
77
|
-
listUserChatRevisionActiveJobs({ userId: row.userId, agentPermanentId, chatId }),
|
|
78
|
-
listUserChatRevisionActiveTimeouts({ userId: row.userId, agentPermanentId, chatId }),
|
|
79
|
-
]);
|
|
80
|
-
|
|
81
|
-
return {
|
|
82
|
-
id: row.id,
|
|
83
|
-
updatedAt: row.updatedAt,
|
|
84
|
-
draftMessage: row.draftMessage,
|
|
85
|
-
source: row.source,
|
|
86
|
-
activeJobs,
|
|
87
|
-
activeTimeouts,
|
|
88
|
-
};
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
/**
|
|
92
|
-
* Lists only active job fields that affect the canonical chat surface.
|
|
93
|
-
*/
|
|
94
|
-
async function listUserChatRevisionActiveJobs(options: {
|
|
95
|
-
userId: number;
|
|
96
|
-
agentPermanentId: string;
|
|
97
|
-
chatId: string;
|
|
98
|
-
}): Promise<Array<UserChatRevisionJob>> {
|
|
99
|
-
const userChatJobTable = await provideUserChatJobTable();
|
|
100
|
-
const { data, error } = await userChatJobTable
|
|
101
|
-
.select('id, status, cancelRequestedAt')
|
|
102
|
-
.eq('chatId', options.chatId)
|
|
103
|
-
.eq('userId', options.userId)
|
|
104
|
-
.eq('agentPermanentId', options.agentPermanentId)
|
|
105
|
-
.in('status', ACTIVE_USER_CHAT_JOB_STATUSES)
|
|
106
|
-
.order('createdAt', { ascending: true });
|
|
107
|
-
|
|
108
|
-
if (error) {
|
|
109
|
-
throw new Error(`Failed to load active user chat job revisions for chat "${options.chatId}": ${error.message}`);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
return (data || []) as Array<UserChatRevisionJob>;
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* Lists only active timeout fields that affect the canonical chat surface.
|
|
117
|
-
*/
|
|
118
|
-
async function listUserChatRevisionActiveTimeouts(options: {
|
|
119
|
-
userId: number;
|
|
120
|
-
agentPermanentId: string;
|
|
121
|
-
chatId: string;
|
|
122
|
-
}): Promise<Array<UserChatRevisionTimeout>> {
|
|
123
|
-
const userChatTimeoutTable = await provideUserChatTimeoutTable();
|
|
124
|
-
const { data, error } = await userChatTimeoutTable
|
|
125
|
-
.select('id, status, message, dueAt, cancelRequestedAt')
|
|
126
|
-
.eq('chatId', options.chatId)
|
|
127
|
-
.eq('userId', options.userId)
|
|
128
|
-
.eq('agentPermanentId', options.agentPermanentId)
|
|
129
|
-
.in('status', ACTIVE_USER_CHAT_TIMEOUT_STATUSES)
|
|
130
|
-
.is('pausedAt', null)
|
|
131
|
-
.order('dueAt', { ascending: true })
|
|
132
|
-
.order('createdAt', { ascending: true });
|
|
133
|
-
|
|
134
|
-
if (error) {
|
|
135
|
-
if (isMissingUserChatTimeoutRelationError(error)) {
|
|
136
|
-
return [];
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
throw new Error(
|
|
140
|
-
`Failed to load active user chat timeout revisions for chat "${options.chatId}": ${error.message}`,
|
|
141
|
-
);
|
|
142
|
-
}
|
|
143
|
-
|
|
144
|
-
return (data || []) as Array<UserChatRevisionTimeout>;
|
|
145
|
-
}
|