@promptbook/cli 0.103.0-48 → 0.103.0-49

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.
Files changed (110) hide show
  1. package/apps/agents-server/README.md +1 -1
  2. package/apps/agents-server/TODO.txt +6 -5
  3. package/apps/agents-server/config.ts +130 -0
  4. package/apps/agents-server/next.config.ts +1 -1
  5. package/apps/agents-server/public/fonts/OpenMoji-black-glyf.woff2 +0 -0
  6. package/apps/agents-server/public/fonts/download-font.js +22 -0
  7. package/apps/agents-server/src/app/[agentName]/[...rest]/page.tsx +6 -0
  8. package/apps/agents-server/src/app/[agentName]/page.tsx +1 -0
  9. package/apps/agents-server/src/app/actions.ts +37 -2
  10. package/apps/agents-server/src/app/agents/[agentName]/AgentChatWrapper.tsx +68 -0
  11. package/apps/agents-server/src/app/agents/[agentName]/AgentQrCode.tsx +55 -0
  12. package/apps/agents-server/src/app/agents/[agentName]/AgentUrlCopy.tsx +4 -5
  13. package/apps/agents-server/src/app/agents/[agentName]/CopyField.tsx +44 -0
  14. package/apps/agents-server/src/app/agents/[agentName]/api/book/route.ts +8 -8
  15. package/apps/agents-server/src/app/agents/[agentName]/api/chat/route.ts +100 -24
  16. package/apps/agents-server/src/app/agents/[agentName]/api/feedback/route.ts +54 -0
  17. package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/route.ts +6 -6
  18. package/apps/agents-server/src/app/agents/[agentName]/api/modelRequirements/systemMessage/route.ts +3 -3
  19. package/apps/agents-server/src/app/agents/[agentName]/api/profile/route.ts +6 -7
  20. package/apps/agents-server/src/app/agents/[agentName]/book/BookEditorWrapper.tsx +4 -5
  21. package/apps/agents-server/src/app/agents/[agentName]/book/page.tsx +9 -2
  22. package/apps/agents-server/src/app/agents/[agentName]/book+chat/AgentBookAndChat.tsx +23 -0
  23. package/apps/agents-server/src/app/agents/[agentName]/book+chat/{AgentBookAndChatComponent.tsx → AgentBookAndChatComponent.tsx.todo} +4 -4
  24. package/apps/agents-server/src/app/agents/[agentName]/book+chat/page.tsx +28 -17
  25. package/apps/agents-server/src/app/agents/[agentName]/book+chat/page.tsx.todo +21 -0
  26. package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatWrapper.tsx +34 -4
  27. package/apps/agents-server/src/app/agents/[agentName]/chat/page.tsx +4 -1
  28. package/apps/agents-server/src/app/agents/[agentName]/generateAgentMetadata.ts +42 -0
  29. package/apps/agents-server/src/app/agents/[agentName]/page.tsx +109 -106
  30. package/apps/agents-server/src/app/agents/page.tsx +1 -1
  31. package/apps/agents-server/src/app/api/auth/login/route.ts +65 -0
  32. package/apps/agents-server/src/app/api/auth/logout/route.ts +7 -0
  33. package/apps/agents-server/src/app/api/metadata/route.ts +116 -0
  34. package/apps/agents-server/src/app/api/upload/route.ts +7 -3
  35. package/apps/agents-server/src/app/api/users/[username]/route.ts +75 -0
  36. package/apps/agents-server/src/app/api/users/route.ts +71 -0
  37. package/apps/agents-server/src/app/globals.css +35 -1
  38. package/apps/agents-server/src/app/layout.tsx +43 -23
  39. package/apps/agents-server/src/app/metadata/MetadataClient.tsx +271 -0
  40. package/apps/agents-server/src/app/metadata/page.tsx +13 -0
  41. package/apps/agents-server/src/app/not-found.tsx +5 -0
  42. package/apps/agents-server/src/app/page.tsx +84 -46
  43. package/apps/agents-server/src/components/Auth/AuthControls.tsx +123 -0
  44. package/apps/agents-server/src/components/ErrorPage/ErrorPage.tsx +33 -0
  45. package/apps/agents-server/src/components/ForbiddenPage/ForbiddenPage.tsx +15 -0
  46. package/apps/agents-server/src/components/Header/Header.tsx +146 -0
  47. package/apps/agents-server/src/components/LayoutWrapper/LayoutWrapper.tsx +27 -0
  48. package/apps/agents-server/src/components/LoginDialog/LoginDialog.tsx +40 -0
  49. package/apps/agents-server/src/components/LoginForm/LoginForm.tsx +109 -0
  50. package/apps/agents-server/src/components/NotFoundPage/NotFoundPage.tsx +17 -0
  51. package/apps/agents-server/src/components/UsersList/UsersList.tsx +190 -0
  52. package/apps/agents-server/src/components/VercelDeploymentCard/VercelDeploymentCard.tsx +60 -0
  53. package/apps/agents-server/src/database/$getTableName.ts +18 -0
  54. package/apps/agents-server/src/database/$provideSupabase.ts +2 -2
  55. package/apps/agents-server/src/database/$provideSupabaseForServer.ts +3 -3
  56. package/apps/agents-server/src/database/getMetadata.ts +31 -0
  57. package/apps/agents-server/src/database/metadataDefaults.ts +32 -0
  58. package/apps/agents-server/src/database/schema.sql +81 -33
  59. package/apps/agents-server/src/database/schema.ts +35 -1
  60. package/apps/agents-server/src/middleware.ts +162 -0
  61. package/apps/agents-server/src/tools/$provideAgentCollectionForServer.ts +11 -7
  62. package/apps/agents-server/src/tools/$provideCdnForServer.ts +1 -1
  63. package/apps/agents-server/src/tools/$provideExecutionToolsForServer.ts +11 -13
  64. package/apps/agents-server/src/tools/$provideOpenAiAssistantExecutionToolsForServer.ts +7 -7
  65. package/apps/agents-server/src/tools/$provideServer.ts +39 -0
  66. package/apps/agents-server/src/utils/auth.ts +33 -0
  67. package/apps/agents-server/src/utils/cdn/utils/nameToSubfolderPath.ts +1 -1
  68. package/apps/agents-server/src/utils/getCurrentUser.ts +32 -0
  69. package/apps/agents-server/src/utils/isIpAllowed.ts +101 -0
  70. package/apps/agents-server/src/utils/isUserAdmin.ts +31 -0
  71. package/apps/agents-server/src/utils/session.ts +50 -0
  72. package/apps/agents-server/tailwind.config.ts +2 -0
  73. package/esm/index.es.js +147 -31
  74. package/esm/index.es.js.map +1 -1
  75. package/esm/typings/servers.d.ts +1 -0
  76. package/esm/typings/src/_packages/types.index.d.ts +2 -0
  77. package/esm/typings/src/_packages/utils.index.d.ts +2 -0
  78. package/esm/typings/src/book-2.0/agent-source/AgentBasicInformation.d.ts +12 -2
  79. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +14 -8
  80. package/esm/typings/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabaseOptions.d.ts +10 -0
  81. package/esm/typings/src/commitments/MESSAGE/InitialMessageCommitmentDefinition.d.ts +28 -0
  82. package/esm/typings/src/commitments/index.d.ts +2 -1
  83. package/esm/typings/src/config.d.ts +1 -0
  84. package/esm/typings/src/errors/DatabaseError.d.ts +2 -2
  85. package/esm/typings/src/errors/WrappedError.d.ts +2 -2
  86. package/esm/typings/src/execution/ExecutionTask.d.ts +2 -2
  87. package/esm/typings/src/execution/LlmExecutionTools.d.ts +6 -1
  88. package/esm/typings/src/llm-providers/_common/register/$provideLlmToolsForWizardOrCli.d.ts +2 -2
  89. package/esm/typings/src/llm-providers/agent/Agent.d.ts +11 -3
  90. package/esm/typings/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +6 -1
  91. package/esm/typings/src/llm-providers/agent/RemoteAgent.d.ts +6 -2
  92. package/esm/typings/src/llm-providers/openai/OpenAiAssistantExecutionTools.d.ts +6 -1
  93. package/esm/typings/src/remote-server/startAgentServer.d.ts +2 -2
  94. package/esm/typings/src/utils/color/Color.d.ts +7 -0
  95. package/esm/typings/src/utils/color/Color.test.d.ts +1 -0
  96. package/esm/typings/src/utils/environment/$getGlobalScope.d.ts +2 -2
  97. package/esm/typings/src/utils/misc/computeHash.d.ts +11 -0
  98. package/esm/typings/src/utils/misc/computeHash.test.d.ts +1 -0
  99. package/esm/typings/src/utils/organization/$sideEffect.d.ts +2 -2
  100. package/esm/typings/src/utils/organization/$side_effect.d.ts +2 -2
  101. package/esm/typings/src/utils/organization/TODO_USE.d.ts +2 -2
  102. package/esm/typings/src/utils/organization/keepUnused.d.ts +2 -2
  103. package/esm/typings/src/utils/organization/preserve.d.ts +3 -3
  104. package/esm/typings/src/utils/organization/really_any.d.ts +7 -0
  105. package/esm/typings/src/utils/serialization/asSerializable.d.ts +2 -2
  106. package/esm/typings/src/version.d.ts +1 -1
  107. package/package.json +1 -1
  108. package/umd/index.umd.js +147 -31
  109. package/umd/index.umd.js.map +1 -1
  110. package/apps/agents-server/config.ts.todo +0 -38
package/umd/index.umd.js CHANGED
@@ -56,7 +56,7 @@
56
56
  * @generated
57
57
  * @see https://github.com/webgptorg/promptbook
58
58
  */
59
- const PROMPTBOOK_ENGINE_VERSION = '0.103.0-48';
59
+ const PROMPTBOOK_ENGINE_VERSION = '0.103.0-49';
60
60
  /**
61
61
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
62
62
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -95,6 +95,7 @@
95
95
  */
96
96
  ];
97
97
  /**
98
+ * TODO: [🐱‍🚀] Auto-federated server from url in here
98
99
  * Note: [💞] Ignore a discrepancy between file name and entity name
99
100
  */
100
101
 
@@ -441,6 +442,9 @@
441
442
  if (hex.length === 3) {
442
443
  return Color.fromHex3(hex);
443
444
  }
445
+ if (hex.length === 4) {
446
+ return Color.fromHex4(hex);
447
+ }
444
448
  if (hex.length === 6) {
445
449
  return Color.fromHex6(hex);
446
450
  }
@@ -461,6 +465,19 @@
461
465
  const b = parseInt(hex.substr(2, 1), 16) * 16;
462
466
  return take(new Color(r, g, b));
463
467
  }
468
+ /**
469
+ * Creates a new Color instance from color in hex format with 4 digits (with alpha channel)
470
+ *
471
+ * @param color in hex for example `09df`
472
+ * @returns Color object
473
+ */
474
+ static fromHex4(hex) {
475
+ const r = parseInt(hex.substr(0, 1), 16) * 16;
476
+ const g = parseInt(hex.substr(1, 1), 16) * 16;
477
+ const b = parseInt(hex.substr(2, 1), 16) * 16;
478
+ const a = parseInt(hex.substr(3, 1), 16) * 16;
479
+ return take(new Color(r, g, b, a));
480
+ }
464
481
  /**
465
482
  * Creates a new Color instance from color in hex format with 6 color digits (without alpha channel)
466
483
  *
@@ -651,7 +668,8 @@
651
668
  * @returns true if the value is a valid hex color string (e.g., `#009edd`, `#fff`, etc.)
652
669
  */
653
670
  static isHexColorString(value) {
654
- return typeof value === 'string' && /^#(?:[0-9a-fA-F]{3}){1,2}$/.test(value);
671
+ return (typeof value === 'string' &&
672
+ /^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{4}|[0-9a-fA-F]{6}|[0-9a-fA-F]{8})$/.test(value));
655
673
  }
656
674
  /**
657
675
  * Creates new Color object
@@ -992,6 +1010,7 @@
992
1010
  ({
993
1011
  TITLE: Color.fromHex('#244EA8'),
994
1012
  LINE: Color.fromHex('#eeeeee'),
1013
+ SEPARATOR: Color.fromHex('#cccccc'),
995
1014
  COMMITMENT: Color.fromHex('#DA0F78'),
996
1015
  PARAMETER: Color.fromHex('#8e44ad'),
997
1016
  });
@@ -2394,7 +2413,7 @@
2394
2413
  TODO: [🧠] Is there a better implementation?
2395
2414
  > const propertyNames = Object.getOwnPropertyNames(objectValue);
2396
2415
  > for (const propertyName of propertyNames) {
2397
- > const value = (objectValue as really_any)[propertyName];
2416
+ > const value = (objectValue as chococake)[propertyName];
2398
2417
  > if (value && typeof value === 'object') {
2399
2418
  > deepClone(value);
2400
2419
  > }
@@ -3213,7 +3232,7 @@
3213
3232
  }
3214
3233
  }
3215
3234
  /**
3216
- * TODO: !!!! Explain that NotFoundError (!!! and other specific errors) has priority over DatabaseError in some contexts
3235
+ * TODO: [🐱‍🚀] Explain that NotFoundError ([🐱‍🚀] and other specific errors) has priority over DatabaseError in some contexts
3217
3236
  */
3218
3237
 
3219
3238
  /**
@@ -12981,6 +13000,18 @@
12981
13000
  * TODO: [🕌] When more than 2 functionalities, split into separate functions
12982
13001
  */
12983
13002
 
13003
+ /**
13004
+ * Computes SHA-256 hash of the given object
13005
+ *
13006
+ * @public exported from `@promptbook/utils`
13007
+ */
13008
+ function computeHash(value) {
13009
+ return cryptoJs.SHA256(hexEncoder__default["default"].parse(spaceTrim__default["default"](valueToString(value)))).toString( /* hex */);
13010
+ }
13011
+ /**
13012
+ * TODO: [🥬][🥬] Use this ACRY
13013
+ */
13014
+
12984
13015
  /**
12985
13016
  * Makes first letter of a string lowercase
12986
13017
  *
@@ -15092,7 +15123,7 @@
15092
15123
  */
15093
15124
 
15094
15125
  /**
15095
- * !!!!!
15126
+ * [🐱‍🚀]
15096
15127
  * Remote server is a proxy server that uses its execution tools internally and exposes the executor interface externally.
15097
15128
  *
15098
15129
  * You can simply use `RemoteExecutionTools` on client-side javascript and connect to your remote server.
@@ -15100,11 +15131,11 @@
15100
15131
  *
15101
15132
  * @see https://github.com/webgptorg/promptbook#remote-server
15102
15133
  * @public exported from `@promptbook/remote-server`
15103
- * <- TODO: !!!! Change to `@promptbook/agent-server`
15134
+ * <- TODO: [🐱‍🚀] Change to `@promptbook/agent-server`
15104
15135
  */
15105
15136
  async function startAgentServer(options) {
15106
15137
  const { port = 4440 } = options;
15107
- // TODO: !!!! [🌕]
15138
+ // TODO: [🐱‍🚀] [🌕]
15108
15139
  const agentsServerRoot = path.join(__dirname, '../apps/agents-server');
15109
15140
  console.trace(`!!! Starting agents server on port ${port}...`);
15110
15141
  console.log(`!!! cwd`, process.cwd());
@@ -15140,7 +15171,7 @@
15140
15171
  startServerCommand.alias('start');
15141
15172
  startServerCommand.action(handleActionErrors(async (path, cliOptions) => {
15142
15173
  const { port: portRaw, reload: isCacheReloaded, verbose: isVerbose } = cliOptions;
15143
- // TODO: !!!! [🌕] DRY
15174
+ // TODO: [🐱‍🚀] [🌕] DRY
15144
15175
  const port = parseInt(portRaw, 10);
15145
15176
  if (isNaN(port) || port <= 0 || port > 65535) {
15146
15177
  console.error(colors__default["default"].red(`Invalid port number: ${portRaw}`));
@@ -15182,11 +15213,11 @@
15182
15213
  TODO_USE(tools);
15183
15214
  TODO_USE(collection);
15184
15215
  */
15185
- // TODO: !!!! Use
15186
- // TODO: !!!! Pass collection and tools to the server starter
15187
- // TODO: !!!! The Next app should be build during the package build step not here
15216
+ // TODO: [🐱‍🚀] Use
15217
+ // TODO: [🐱‍🚀] Pass collection and tools to the server starter
15218
+ // TODO: [🐱‍🚀] The Next app should be build during the package build step not here
15188
15219
  /*
15189
- // TODO: !!!! Run this conditionally only in production mode in dev mode use `next dev`
15220
+ // TODO: [🐱‍🚀] Run this conditionally only in production mode in dev mode use `next dev`
15190
15221
  await $execCommand({
15191
15222
  cwd: './apps/agents-server',
15192
15223
  command: `next build`,
@@ -20399,11 +20430,12 @@
20399
20430
  *
20400
20431
  * This is useful for calling OpenAI API with a single assistant, for more wide usage use `OpenAiExecutionTools`.
20401
20432
  *
20402
- * !!! Note: [🦖] There are several different things in Promptbook:
20433
+ * Note: [🦖] There are several different things in Promptbook:
20403
20434
  * - `Agent` - which represents an AI Agent with its source, memories, actions, etc. Agent is a higher-level abstraction which is internally using:
20404
20435
  * - `LlmExecutionTools` - which wraps one or more LLM models and provides an interface to execute them
20405
20436
  * - `AgentLlmExecutionTools` - which is a specific implementation of `LlmExecutionTools` that wraps another LlmExecutionTools and applies agent-specific system prompts and requirements
20406
20437
  * - `OpenAiAssistantExecutionTools` - which is a specific implementation of `LlmExecutionTools` for OpenAI models with assistant capabilities, recommended for usage in `Agent` or `AgentLlmExecutionTools`
20438
+ * - `RemoteAgent` - which is an `Agent` that connects to a Promptbook Agents Server
20407
20439
  *
20408
20440
  * @public exported from `@promptbook/openai`
20409
20441
  */
@@ -20438,6 +20470,12 @@
20438
20470
  * Calls OpenAI API to use a chat model.
20439
20471
  */
20440
20472
  async callChatModel(prompt) {
20473
+ return this.callChatModelStream(prompt, () => { });
20474
+ }
20475
+ /**
20476
+ * Calls OpenAI API to use a chat model with streaming.
20477
+ */
20478
+ async callChatModelStream(prompt, onProgress) {
20441
20479
  var _a, _b, _c;
20442
20480
  if (this.options.isVerbose) {
20443
20481
  console.info('💬 OpenAI callChatModel call', { prompt });
@@ -20505,21 +20543,24 @@
20505
20543
  console.info('connect', stream.currentEvent);
20506
20544
  }
20507
20545
  });
20508
- /*
20509
- stream.on('messageDelta', (messageDelta) => {
20510
- if (
20511
- this.options.isVerbose &&
20512
- messageDelta &&
20513
- messageDelta.content &&
20514
- messageDelta.content[0] &&
20515
- messageDelta.content[0].type === 'text'
20516
- ) {
20517
- console.info('messageDelta', messageDelta.content[0].text?.value);
20546
+ stream.on('textDelta', (textDelta, snapshot) => {
20547
+ if (this.options.isVerbose && textDelta.value) {
20548
+ console.info('textDelta', textDelta.value);
20518
20549
  }
20519
-
20520
- // <- TODO: [🐚] Make streaming and running tasks working
20550
+ const chunk = {
20551
+ content: textDelta.value || '',
20552
+ modelName: 'assistant',
20553
+ timing: {
20554
+ start,
20555
+ complete: $getCurrentDate(),
20556
+ },
20557
+ usage: UNCERTAIN_USAGE,
20558
+ rawPromptContent,
20559
+ rawRequest,
20560
+ rawResponse: snapshot,
20561
+ };
20562
+ onProgress(chunk);
20521
20563
  });
20522
- */
20523
20564
  stream.on('messageCreated', (message) => {
20524
20565
  if (this.options.isVerbose) {
20525
20566
  console.info('messageCreated', message);
@@ -20555,7 +20596,7 @@
20555
20596
  }
20556
20597
  return exportJson({
20557
20598
  name: 'promptResult',
20558
- message: `Result of \`OpenAiAssistantExecutionTools.callChatModel\``,
20599
+ message: `Result of \`OpenAiAssistantExecutionTools.callChatModelStream\``,
20559
20600
  order: [],
20560
20601
  value: {
20561
20602
  content: resultContent,
@@ -20694,9 +20735,9 @@
20694
20735
  }
20695
20736
  const assistant = await client.beta.assistants.create(assistantConfig);
20696
20737
  console.log(`✅ Assistant created: ${assistant.id}`);
20697
- // TODO: !!!! Try listing existing assistants
20698
- // TODO: !!!! Try marking existing assistants by DISCRIMINANT
20699
- // TODO: !!!! Allow to update and reconnect to existing assistants
20738
+ // TODO: [🐱‍🚀] Try listing existing assistants
20739
+ // TODO: [🐱‍🚀] Try marking existing assistants by DISCRIMINANT
20740
+ // TODO: [🐱‍🚀] Allow to update and reconnect to existing assistants
20700
20741
  return new OpenAiAssistantExecutionTools({
20701
20742
  ...this.options,
20702
20743
  isCreatingNewAssistantsAllowed: false,
@@ -23018,6 +23059,60 @@
23018
23059
  * Note: [💞] Ignore a discrepancy between file name and entity name
23019
23060
  */
23020
23061
 
23062
+ /**
23063
+ * INITIAL MESSAGE commitment definition
23064
+ *
23065
+ * The INITIAL MESSAGE commitment defines the first message that the user sees when opening the chat.
23066
+ * It is used to greet the user and set the tone of the conversation.
23067
+ *
23068
+ * Example usage in agent source:
23069
+ *
23070
+ * ```book
23071
+ * INITIAL MESSAGE Hello! I am ready to help you with your tasks.
23072
+ * ```
23073
+ *
23074
+ * @private [🪔] Maybe export the commitments through some package
23075
+ */
23076
+ class InitialMessageCommitmentDefinition extends BaseCommitmentDefinition {
23077
+ constructor() {
23078
+ super('INITIAL MESSAGE');
23079
+ }
23080
+ /**
23081
+ * Short one-line description of INITIAL MESSAGE.
23082
+ */
23083
+ get description() {
23084
+ return 'Defines the **initial message** shown to the user when the chat starts.';
23085
+ }
23086
+ /**
23087
+ * Markdown documentation for INITIAL MESSAGE commitment.
23088
+ */
23089
+ get documentation() {
23090
+ return spaceTrim.spaceTrim(`
23091
+ # ${this.type}
23092
+
23093
+ Defines the first message that the user sees when opening the chat. This message is purely for display purposes in the UI and does not inherently become part of the LLM's system prompt context (unless also included via other means).
23094
+
23095
+ ## Key aspects
23096
+
23097
+ - Used to greet the user.
23098
+ - Sets the tone of the conversation.
23099
+ - Displayed immediately when the chat interface loads.
23100
+
23101
+ ## Examples
23102
+
23103
+ \`\`\`book
23104
+ Support Agent
23105
+
23106
+ PERSONA You are a helpful support agent.
23107
+ INITIAL MESSAGE Hi there! How can I assist you today?
23108
+ \`\`\`
23109
+ `);
23110
+ }
23111
+ applyToAgentModelRequirements(requirements, content) {
23112
+ return requirements;
23113
+ }
23114
+ }
23115
+
23021
23116
  /**
23022
23117
  * MESSAGE commitment definition
23023
23118
  *
@@ -24179,6 +24274,7 @@
24179
24274
  new NoteCommitmentDefinition('NONCE'),
24180
24275
  new GoalCommitmentDefinition('GOAL'),
24181
24276
  new GoalCommitmentDefinition('GOALS'),
24277
+ new InitialMessageCommitmentDefinition(),
24182
24278
  new MessageCommitmentDefinition('MESSAGE'),
24183
24279
  new MessageCommitmentDefinition('MESSAGES'),
24184
24280
  new ScenarioCommitmentDefinition('SCENARIO'),
@@ -24557,7 +24653,7 @@
24557
24653
  * @public exported from `@promptbook/core`
24558
24654
  */
24559
24655
  function computeAgentHash(agentSource) {
24560
- return cryptoJs.SHA256(hexEncoder__default["default"].parse(agentSource /* <- TODO: !!!!! spaceTrim */)).toString( /* hex */);
24656
+ return computeHash(agentSource);
24561
24657
  }
24562
24658
 
24563
24659
  /**
@@ -24606,13 +24702,31 @@
24606
24702
  }
24607
24703
  personaDescription += commitment.content;
24608
24704
  }
24705
+ let initialMessage = null;
24706
+ for (const commitment of parseResult.commitments) {
24707
+ if (commitment.type !== 'INITIAL MESSAGE') {
24708
+ continue;
24709
+ }
24710
+ // Note: Initial message override logic - later overrides earlier
24711
+ // Or should it append? Usually initial message is just one block.
24712
+ // Let's stick to "later overrides earlier" for simplicity, or just take the last one.
24713
+ initialMessage = commitment.content;
24714
+ }
24609
24715
  const meta = {};
24716
+ const links = [];
24610
24717
  for (const commitment of parseResult.commitments) {
24718
+ if (commitment.type === 'META LINK') {
24719
+ links.push(spaceTrim__default["default"](commitment.content));
24720
+ continue;
24721
+ }
24611
24722
  if (commitment.type !== 'META') {
24612
24723
  continue;
24613
24724
  }
24614
24725
  // Parse META commitments - format is "META TYPE content"
24615
24726
  const metaTypeRaw = commitment.content.split(' ')[0] || 'NONE';
24727
+ if (metaTypeRaw === 'LINK') {
24728
+ links.push(spaceTrim__default["default"](commitment.content.substring(metaTypeRaw.length)));
24729
+ }
24616
24730
  const metaType = normalizeTo_camelCase(metaTypeRaw);
24617
24731
  meta[metaType] = spaceTrim__default["default"](commitment.content.substring(metaTypeRaw.length));
24618
24732
  }
@@ -24628,7 +24742,9 @@
24628
24742
  agentName: normalizeAgentName(parseResult.agentName || createDefaultAgentName(agentSource)),
24629
24743
  agentHash,
24630
24744
  personaDescription,
24745
+ initialMessage,
24631
24746
  meta,
24747
+ links,
24632
24748
  parameters,
24633
24749
  };
24634
24750
  }