@promptbook/cli 0.112.0-110 → 0.112.0-111
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/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/components/ApplicationErrorPage/ApplicationErrorPage.tsx +118 -12
- 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/importAgent.ts +1 -57
- package/apps/agents-server/src/utils/importAgentWithFallback.ts +0 -10
- package/apps/agents-server/src/utils/userChat.ts +0 -1
- package/esm/index.es.js +18 -11
- package/esm/index.es.js.map +1 -1
- 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 +6 -1
- package/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.ts +91 -14
- package/src/other/templates/getTemplatesPipelineCollection.ts +920 -617
- package/src/version.ts +2 -2
- package/src/versions.txt +1 -0
- package/umd/index.umd.js +18 -11
- package/umd/index.umd.js.map +1 -1
- 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
|
@@ -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/esm/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-110`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -398,7 +398,12 @@ function startNextServer(options: {
|
|
|
398
398
|
options.logStreams.runner,
|
|
399
399
|
`Starting the Agents Server Next process in ${nextRuntimeModeLabel} mode.`,
|
|
400
400
|
);
|
|
401
|
-
const nextArguments = [
|
|
401
|
+
const nextArguments = [
|
|
402
|
+
options.nextCliPath,
|
|
403
|
+
options.options.nextRuntimeMode,
|
|
404
|
+
'--port',
|
|
405
|
+
String(options.options.port),
|
|
406
|
+
];
|
|
402
407
|
const hostname = options.childEnvironment[PTBK_HOSTNAME_ENV]?.trim();
|
|
403
408
|
|
|
404
409
|
if (hostname) {
|
|
@@ -49,6 +49,19 @@ function normalizeHistoryVersionName(versionName: string | null | undefined): st
|
|
|
49
49
|
return normalizedVersionName.length > 0 ? normalizedVersionName : null;
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
+
/**
|
|
53
|
+
* Builds a Supabase `.or()` filter for agent name or permanent id lookups.
|
|
54
|
+
*
|
|
55
|
+
* @param agentNameOrPermanentId - Agent name or stable permanent identifier to match.
|
|
56
|
+
* @returns `.or()` filter string safe to pass to Supabase.
|
|
57
|
+
*
|
|
58
|
+
* @private internal helper of `AgentCollectionInSupabase`
|
|
59
|
+
*/
|
|
60
|
+
function buildAgentNameOrPermanentIdFilter(agentNameOrPermanentId: string): string {
|
|
61
|
+
const encodedAgentIdentifier = encodeURIComponent(agentNameOrPermanentId);
|
|
62
|
+
return `agentName.eq.${encodedAgentIdentifier},permanentId.eq.${encodedAgentIdentifier}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
52
65
|
/**
|
|
53
66
|
* One saved Agent history row without the full source payload.
|
|
54
67
|
*/
|
|
@@ -69,6 +82,16 @@ type AgentHistorySnapshot = AgentHistoryMetadata & {
|
|
|
69
82
|
readonly agentSource: string;
|
|
70
83
|
};
|
|
71
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Minimal database row used to build public agent information.
|
|
87
|
+
*
|
|
88
|
+
* @private internal type of `AgentCollectionInSupabase`
|
|
89
|
+
*/
|
|
90
|
+
type AgentBasicInformationRow = Pick<
|
|
91
|
+
AgentsDatabaseSchema['public']['Tables']['Agent']['Row'],
|
|
92
|
+
'agentName' | 'agentProfile' | 'permanentId'
|
|
93
|
+
>;
|
|
94
|
+
|
|
72
95
|
/**
|
|
73
96
|
* Agent collection stored in a Supabase table.
|
|
74
97
|
*
|
|
@@ -127,24 +150,78 @@ export class AgentCollectionInSupabase /* TODO: [🌈][🐱🚀] implements A
|
|
|
127
150
|
console.info(`Found ${selectResult.data.length} agents in directory`);
|
|
128
151
|
}
|
|
129
152
|
|
|
130
|
-
return selectResult.data.map((
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
153
|
+
return selectResult.data.map((row) => this.mapAgentBasicInformationRow(row, isVerbose));
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
/**
|
|
157
|
+
* Finds one active agent profile by its human-readable name or permanent id.
|
|
158
|
+
*
|
|
159
|
+
* This keeps route-level lookups from loading the whole agent collection when only
|
|
160
|
+
* one canonical route identifier is needed.
|
|
161
|
+
*
|
|
162
|
+
* @param agentNameOrPermanentId - Agent name or stable permanent identifier.
|
|
163
|
+
* @returns Matching active agent profile or `null` when not found.
|
|
164
|
+
*
|
|
165
|
+
* @public exported from `@promptbook/core`
|
|
166
|
+
*/
|
|
167
|
+
public async findAgentBasicInformation(
|
|
168
|
+
agentNameOrPermanentId: string_agent_name | string_agent_permanent_id,
|
|
169
|
+
): Promise<AgentBasicInformation | null> {
|
|
170
|
+
const { isVerbose = DEFAULT_IS_VERBOSE } = this.options || {};
|
|
171
|
+
const selectResult = await this.supabaseClient
|
|
172
|
+
.from(this.getTableName('Agent'))
|
|
173
|
+
.select('agentName,agentProfile,permanentId')
|
|
174
|
+
.or(buildAgentNameOrPermanentIdFilter(agentNameOrPermanentId))
|
|
175
|
+
.is('deletedAt', null)
|
|
176
|
+
.order('createdAt', { ascending: true })
|
|
177
|
+
.limit(1);
|
|
178
|
+
|
|
179
|
+
if (selectResult.error) {
|
|
180
|
+
throw new DatabaseError(
|
|
181
|
+
spaceTrim(
|
|
182
|
+
(block) => `
|
|
183
|
+
|
|
184
|
+
Error fetching agent "${agentNameOrPermanentId}" from Supabase:
|
|
185
|
+
|
|
186
|
+
${block(selectResult.error.message)}
|
|
187
|
+
`,
|
|
188
|
+
),
|
|
189
|
+
);
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
const row = selectResult.data?.[0];
|
|
193
|
+
return row ? this.mapAgentBasicInformationRow(row, isVerbose) : null;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* Converts one database row into public agent information.
|
|
198
|
+
*
|
|
199
|
+
* @param row - Database row carrying the persisted profile snapshot.
|
|
200
|
+
* @param isVerbose - Whether profile-name mismatches should be logged.
|
|
201
|
+
* @returns Agent profile with canonical database name and permanent id.
|
|
202
|
+
*
|
|
203
|
+
* @private internal helper of `AgentCollectionInSupabase`
|
|
204
|
+
*/
|
|
205
|
+
private mapAgentBasicInformationRow(
|
|
206
|
+
{ agentName, agentProfile, permanentId }: AgentBasicInformationRow,
|
|
207
|
+
isVerbose: boolean,
|
|
208
|
+
): AgentBasicInformation {
|
|
209
|
+
if (isVerbose && (agentProfile as AgentBasicInformation).agentName !== agentName) {
|
|
210
|
+
console.warn(
|
|
211
|
+
spaceTrim(`
|
|
134
212
|
Agent name mismatch for agent "${agentName}". Using name from database.
|
|
135
213
|
|
|
136
214
|
agentName: "${agentName}"
|
|
137
215
|
agentProfile.agentName: "${(agentProfile as AgentBasicInformation).agentName}"
|
|
138
216
|
`),
|
|
139
|
-
|
|
140
|
-
|
|
217
|
+
);
|
|
218
|
+
}
|
|
141
219
|
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
});
|
|
220
|
+
return {
|
|
221
|
+
...(agentProfile as AgentBasicInformation),
|
|
222
|
+
agentName,
|
|
223
|
+
permanentId: permanentId || (agentProfile as AgentBasicInformation).permanentId,
|
|
224
|
+
};
|
|
148
225
|
}
|
|
149
226
|
|
|
150
227
|
/**
|
|
@@ -156,7 +233,7 @@ export class AgentCollectionInSupabase /* TODO: [🌈][🐱🚀] implements A
|
|
|
156
233
|
const selectResult = await this.supabaseClient
|
|
157
234
|
.from(this.getTableName('Agent'))
|
|
158
235
|
.select('permanentId')
|
|
159
|
-
.or(
|
|
236
|
+
.or(buildAgentNameOrPermanentIdFilter(agentNameOrPermanentId))
|
|
160
237
|
.order('createdAt', { ascending: true }) // Pick oldest if multiple match by name
|
|
161
238
|
.limit(1);
|
|
162
239
|
|
|
@@ -175,7 +252,7 @@ export class AgentCollectionInSupabase /* TODO: [🌈][🐱🚀] implements A
|
|
|
175
252
|
const selectResult = await this.supabaseClient
|
|
176
253
|
.from(this.getTableName('Agent'))
|
|
177
254
|
.select('agentSource')
|
|
178
|
-
.or(
|
|
255
|
+
.or(buildAgentNameOrPermanentIdFilter(agentNameOrPermanentId))
|
|
179
256
|
.is('deletedAt', null)
|
|
180
257
|
.order('createdAt', { ascending: true }) // Pick oldest if multiple match by name
|
|
181
258
|
.limit(1);
|