@promptbook/core 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.
@@ -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
  */
@@ -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-109`).
18
+ * It follows semantic versioning (e.g., `0.112.0-110`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/core",
3
- "version": "0.112.0-110",
3
+ "version": "0.112.0-111",
4
4
  "description": "Promptbook: Create persistent AI agents that turn your company's scattered knowledge into action",
5
5
  "private": false,
6
6
  "sideEffects": false,
package/umd/index.umd.js CHANGED
@@ -27,7 +27,7 @@
27
27
  * @generated
28
28
  * @see https://github.com/webgptorg/promptbook
29
29
  */
30
- const PROMPTBOOK_ENGINE_VERSION = '0.112.0-110';
30
+ const PROMPTBOOK_ENGINE_VERSION = '0.112.0-111';
31
31
  /**
32
32
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
33
33
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -29359,6 +29359,18 @@
29359
29359
  const normalizedVersionName = versionName.trim();
29360
29360
  return normalizedVersionName.length > 0 ? normalizedVersionName : null;
29361
29361
  }
29362
+ /**
29363
+ * Builds a Supabase `.or()` filter for agent name or permanent id lookups.
29364
+ *
29365
+ * @param agentNameOrPermanentId - Agent name or stable permanent identifier to match.
29366
+ * @returns `.or()` filter string safe to pass to Supabase.
29367
+ *
29368
+ * @private internal helper of `AgentCollectionInSupabase`
29369
+ */
29370
+ function buildAgentNameOrPermanentIdFilter(agentNameOrPermanentId) {
29371
+ const encodedAgentIdentifier = encodeURIComponent(agentNameOrPermanentId);
29372
+ return `agentName.eq.${encodedAgentIdentifier},permanentId.eq.${encodedAgentIdentifier}`;
29373
+ }
29362
29374
  /**
29363
29375
  * Agent collection stored in a Supabase table.
29364
29376
  *
@@ -29406,21 +29418,63 @@
29406
29418
  if (isVerbose) {
29407
29419
  console.info(`Found ${selectResult.data.length} agents in directory`);
29408
29420
  }
29409
- return selectResult.data.map(({ agentName, agentProfile, permanentId }) => {
29410
- if (isVerbose && agentProfile.agentName !== agentName) {
29411
- console.warn(spaceTrim(`
29421
+ return selectResult.data.map((row) => this.mapAgentBasicInformationRow(row, isVerbose));
29422
+ }
29423
+ /**
29424
+ * Finds one active agent profile by its human-readable name or permanent id.
29425
+ *
29426
+ * This keeps route-level lookups from loading the whole agent collection when only
29427
+ * one canonical route identifier is needed.
29428
+ *
29429
+ * @param agentNameOrPermanentId - Agent name or stable permanent identifier.
29430
+ * @returns Matching active agent profile or `null` when not found.
29431
+ *
29432
+ * @public exported from `@promptbook/core`
29433
+ */
29434
+ async findAgentBasicInformation(agentNameOrPermanentId) {
29435
+ var _a;
29436
+ const { isVerbose = exports.DEFAULT_IS_VERBOSE } = this.options || {};
29437
+ const selectResult = await this.supabaseClient
29438
+ .from(this.getTableName('Agent'))
29439
+ .select('agentName,agentProfile,permanentId')
29440
+ .or(buildAgentNameOrPermanentIdFilter(agentNameOrPermanentId))
29441
+ .is('deletedAt', null)
29442
+ .order('createdAt', { ascending: true })
29443
+ .limit(1);
29444
+ if (selectResult.error) {
29445
+ throw new DatabaseError(spaceTrim((block) => `
29446
+
29447
+ Error fetching agent "${agentNameOrPermanentId}" from Supabase:
29448
+
29449
+ ${block(selectResult.error.message)}
29450
+ `));
29451
+ }
29452
+ const row = (_a = selectResult.data) === null || _a === void 0 ? void 0 : _a[0];
29453
+ return row ? this.mapAgentBasicInformationRow(row, isVerbose) : null;
29454
+ }
29455
+ /**
29456
+ * Converts one database row into public agent information.
29457
+ *
29458
+ * @param row - Database row carrying the persisted profile snapshot.
29459
+ * @param isVerbose - Whether profile-name mismatches should be logged.
29460
+ * @returns Agent profile with canonical database name and permanent id.
29461
+ *
29462
+ * @private internal helper of `AgentCollectionInSupabase`
29463
+ */
29464
+ mapAgentBasicInformationRow({ agentName, agentProfile, permanentId }, isVerbose) {
29465
+ if (isVerbose && agentProfile.agentName !== agentName) {
29466
+ console.warn(spaceTrim(`
29412
29467
  Agent name mismatch for agent "${agentName}". Using name from database.
29413
29468
 
29414
29469
  agentName: "${agentName}"
29415
29470
  agentProfile.agentName: "${agentProfile.agentName}"
29416
29471
  `));
29417
- }
29418
- return {
29419
- ...agentProfile,
29420
- agentName,
29421
- permanentId: permanentId || agentProfile.permanentId,
29422
- };
29423
- });
29472
+ }
29473
+ return {
29474
+ ...agentProfile,
29475
+ agentName,
29476
+ permanentId: permanentId || agentProfile.permanentId,
29477
+ };
29424
29478
  }
29425
29479
  /**
29426
29480
  * Retrieves the permanent ID of an agent by its name or permanent ID.
@@ -29429,7 +29483,7 @@
29429
29483
  const selectResult = await this.supabaseClient
29430
29484
  .from(this.getTableName('Agent'))
29431
29485
  .select('permanentId')
29432
- .or(`agentName.eq.${agentNameOrPermanentId},permanentId.eq.${agentNameOrPermanentId}`)
29486
+ .or(buildAgentNameOrPermanentIdFilter(agentNameOrPermanentId))
29433
29487
  .order('createdAt', { ascending: true }) // Pick oldest if multiple match by name
29434
29488
  .limit(1);
29435
29489
  if (selectResult.error || !selectResult.data || selectResult.data.length === 0) {
@@ -29444,7 +29498,7 @@
29444
29498
  const selectResult = await this.supabaseClient
29445
29499
  .from(this.getTableName('Agent'))
29446
29500
  .select('agentSource')
29447
- .or(`agentName.eq.${agentNameOrPermanentId},permanentId.eq.${agentNameOrPermanentId}`)
29501
+ .or(buildAgentNameOrPermanentIdFilter(agentNameOrPermanentId))
29448
29502
  .is('deletedAt', null)
29449
29503
  .order('createdAt', { ascending: true }) // Pick oldest if multiple match by name
29450
29504
  .limit(1);