@promptbook/core 0.112.0-41 → 0.112.0-42
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/esm/index.es.js +61 -41
- package/esm/index.es.js.map +1 -1
- package/esm/src/cli/cli-commands/coder/verify.test.d.ts +1 -0
- package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +2 -14
- package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/createAgentPersistenceRecords.d.ts +40 -0
- package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/createAgentPersistenceRecords.test.d.ts +1 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.umd.js +61 -41
- package/umd/index.umd.js.map +1 -1
- package/umd/src/cli/cli-commands/coder/verify.test.d.ts +1 -0
- package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +2 -14
- package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/createAgentPersistenceRecords.d.ts +40 -0
- package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/createAgentPersistenceRecords.test.d.ts +1 -0
- package/umd/src/version.d.ts +1 -1
package/esm/index.es.js
CHANGED
|
@@ -28,7 +28,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
28
28
|
* @generated
|
|
29
29
|
* @see https://github.com/webgptorg/promptbook
|
|
30
30
|
*/
|
|
31
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
31
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-42';
|
|
32
32
|
/**
|
|
33
33
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
34
34
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -23457,6 +23457,60 @@ function stripMetaIdLines(agentSource) {
|
|
|
23457
23457
|
return strippedLines.join('\n');
|
|
23458
23458
|
}
|
|
23459
23459
|
|
|
23460
|
+
/**
|
|
23461
|
+
* Builds normalized insert rows for a newly created persisted agent.
|
|
23462
|
+
*
|
|
23463
|
+
* @param agentSource - Source content of the agent.
|
|
23464
|
+
* @param options - Optional folder placement, ordering, and visibility overrides.
|
|
23465
|
+
* @param createdAt - Shared creation timestamp used across all persisted rows.
|
|
23466
|
+
* @returns Insert rows and the created agent profile.
|
|
23467
|
+
*
|
|
23468
|
+
* @private shared persistence helper for `AgentCollectionInSupabase`
|
|
23469
|
+
*/
|
|
23470
|
+
function createAgentPersistenceRecords(agentSource, options = {}, createdAt = new Date().toISOString()) {
|
|
23471
|
+
const preparedAgentSource = prepareAgentSourceForPersistence(agentSource);
|
|
23472
|
+
const { agentProfile, agentSource: normalizedAgentSource } = preparedAgentSource;
|
|
23473
|
+
const permanentId = preparedAgentSource.permanentId || $randomBase58(14);
|
|
23474
|
+
const { agentName, agentHash } = agentProfile;
|
|
23475
|
+
const agentInsertRecord = {
|
|
23476
|
+
agentName,
|
|
23477
|
+
agentHash,
|
|
23478
|
+
permanentId,
|
|
23479
|
+
agentProfile,
|
|
23480
|
+
createdAt,
|
|
23481
|
+
updatedAt: null,
|
|
23482
|
+
promptbookEngineVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
23483
|
+
usage: ZERO_USAGE,
|
|
23484
|
+
agentSource: normalizedAgentSource,
|
|
23485
|
+
};
|
|
23486
|
+
if (options.folderId !== undefined) {
|
|
23487
|
+
agentInsertRecord.folderId = options.folderId;
|
|
23488
|
+
}
|
|
23489
|
+
if (options.sortOrder !== undefined) {
|
|
23490
|
+
agentInsertRecord.sortOrder = options.sortOrder;
|
|
23491
|
+
}
|
|
23492
|
+
if (options.visibility !== undefined) {
|
|
23493
|
+
agentInsertRecord.visibility = options.visibility;
|
|
23494
|
+
}
|
|
23495
|
+
return {
|
|
23496
|
+
createdAgent: {
|
|
23497
|
+
...agentProfile,
|
|
23498
|
+
permanentId,
|
|
23499
|
+
},
|
|
23500
|
+
agentInsertRecord,
|
|
23501
|
+
agentHistoryInsertRecord: {
|
|
23502
|
+
createdAt,
|
|
23503
|
+
agentName,
|
|
23504
|
+
permanentId,
|
|
23505
|
+
agentHash,
|
|
23506
|
+
previousAgentHash: null,
|
|
23507
|
+
agentSource: normalizedAgentSource,
|
|
23508
|
+
promptbookEngineVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
23509
|
+
versionName: null,
|
|
23510
|
+
},
|
|
23511
|
+
};
|
|
23512
|
+
}
|
|
23513
|
+
|
|
23460
23514
|
/**
|
|
23461
23515
|
* Normalizes optional history version name before persistence.
|
|
23462
23516
|
*
|
|
@@ -23580,52 +23634,18 @@ class AgentCollectionInSupabase /* TODO: [🌈][🐱🚀] implements AgentCol
|
|
|
23580
23634
|
* @param options - Optional folder placement and ordering data.
|
|
23581
23635
|
*/
|
|
23582
23636
|
async createAgent(agentSource, options = {}) {
|
|
23583
|
-
const
|
|
23584
|
-
const {
|
|
23585
|
-
|
|
23586
|
-
const { agentName, agentHash } = agentProfile;
|
|
23587
|
-
if (!permanentId) {
|
|
23588
|
-
permanentId = $randomBase58(14);
|
|
23589
|
-
}
|
|
23590
|
-
const insertPayload = {
|
|
23591
|
-
agentName,
|
|
23592
|
-
agentHash,
|
|
23593
|
-
permanentId,
|
|
23594
|
-
agentProfile,
|
|
23595
|
-
createdAt: new Date().toISOString(),
|
|
23596
|
-
updatedAt: null,
|
|
23597
|
-
promptbookEngineVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
23598
|
-
usage: ZERO_USAGE,
|
|
23599
|
-
agentSource: normalizedAgentSource,
|
|
23600
|
-
};
|
|
23601
|
-
if (options.folderId !== undefined) {
|
|
23602
|
-
insertPayload.folderId = options.folderId;
|
|
23603
|
-
}
|
|
23604
|
-
if (options.sortOrder !== undefined) {
|
|
23605
|
-
insertPayload.sortOrder = options.sortOrder;
|
|
23606
|
-
}
|
|
23607
|
-
if (options.visibility !== undefined) {
|
|
23608
|
-
insertPayload.visibility = options.visibility;
|
|
23609
|
-
}
|
|
23610
|
-
const insertAgentResult = await this.supabaseClient.from(this.getTableName('Agent')).insert(insertPayload);
|
|
23637
|
+
const createdAt = new Date().toISOString();
|
|
23638
|
+
const { createdAgent, agentInsertRecord, agentHistoryInsertRecord } = createAgentPersistenceRecords(agentSource, options, createdAt);
|
|
23639
|
+
const insertAgentResult = await this.supabaseClient.from(this.getTableName('Agent')).insert(agentInsertRecord);
|
|
23611
23640
|
if (insertAgentResult.error) {
|
|
23612
23641
|
throw new DatabaseError(spaceTrim((block) => `
|
|
23613
|
-
Error creating agent "${
|
|
23642
|
+
Error creating agent "${createdAgent.agentName}" in Supabase:
|
|
23614
23643
|
|
|
23615
23644
|
${block(insertAgentResult.error.message)}
|
|
23616
23645
|
`));
|
|
23617
23646
|
}
|
|
23618
|
-
await this.insertAgentHistoryRow(
|
|
23619
|
-
|
|
23620
|
-
agentName,
|
|
23621
|
-
permanentId,
|
|
23622
|
-
agentHash,
|
|
23623
|
-
previousAgentHash: null,
|
|
23624
|
-
agentSource: normalizedAgentSource,
|
|
23625
|
-
promptbookEngineVersion: PROMPTBOOK_ENGINE_VERSION,
|
|
23626
|
-
versionName: null,
|
|
23627
|
-
});
|
|
23628
|
-
return { ...agentProfile, permanentId };
|
|
23647
|
+
await this.insertAgentHistoryRow(agentHistoryInsertRecord);
|
|
23648
|
+
return createdAgent;
|
|
23629
23649
|
}
|
|
23630
23650
|
/**
|
|
23631
23651
|
* Updates an existing agent in the collection
|