@promptbook/core 0.114.0-5 → 0.114.0-8

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 (75) hide show
  1. package/esm/index.es.js +131 -50
  2. package/esm/index.es.js.map +1 -1
  3. package/esm/src/avatars/renderAvatarVisualTerminalText.d.ts +80 -0
  4. package/esm/src/avatars/types/AvatarVisualDefinition.d.ts +54 -0
  5. package/esm/src/book-3.0/AgentTeamConversationWorkspace.d.ts +85 -0
  6. package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +3 -2
  7. package/esm/src/book-components/Chat/utils/renderMarkdown.d.ts +12 -3
  8. package/esm/src/cli/cli-commands/coder/boilerplateCount.d.ts +1 -1
  9. package/esm/src/cli/cli-commands/coder/generate-boilerplates.d.ts +1 -1
  10. package/esm/src/cli/cli-commands/common/{harness/$askForHarnessInstallationApproval.d.ts → npm/$askForNpmPackageInstallationApproval.d.ts} +2 -2
  11. package/esm/src/cli/cli-commands/common/{harness/$resolveLatestHarnessVersion.d.ts → npm/$resolveLatestNpmPackageVersion.d.ts} +2 -3
  12. package/esm/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.d.ts +12 -0
  13. package/esm/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.d.ts +9 -0
  14. package/esm/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.d.ts +9 -0
  15. package/esm/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.d.ts +14 -0
  16. package/esm/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.test.d.ts +1 -0
  17. package/esm/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.d.ts +12 -0
  18. package/esm/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.test.d.ts +1 -0
  19. package/esm/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.d.ts +10 -0
  20. package/esm/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallation.d.ts +39 -0
  21. package/esm/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallationStatus.d.ts +26 -0
  22. package/esm/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.d.ts +7 -0
  23. package/esm/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.test.d.ts +1 -0
  24. package/esm/src/cli/cli-commands/common/promptbook-cli/formatPromptbookCliInstallationWarning.d.ts +7 -0
  25. package/esm/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.d.ts +3 -3
  26. package/esm/src/utils/agents/terminalAgentAvatarVisual.d.ts +5 -2
  27. package/esm/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +6 -0
  28. package/esm/src/utils/ascii-art/createAnsiColorCode.d.ts +46 -0
  29. package/esm/src/utils/misc/debounce.d.ts +4 -2
  30. package/esm/src/utils/misc/debounce.test.d.ts +1 -0
  31. package/esm/src/version.d.ts +1 -1
  32. package/package.json +1 -1
  33. package/umd/index.umd.js +131 -50
  34. package/umd/index.umd.js.map +1 -1
  35. package/umd/src/avatars/renderAvatarVisualTerminalText.d.ts +80 -0
  36. package/umd/src/avatars/renderAvatarVisualTerminalText.test.d.ts +1 -0
  37. package/umd/src/avatars/types/AvatarVisualDefinition.d.ts +54 -0
  38. package/umd/src/book-3.0/AgentTeamConversationWorkspace.d.ts +85 -0
  39. package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +3 -2
  40. package/umd/src/book-components/Chat/utils/renderMarkdown.d.ts +12 -3
  41. package/umd/src/cli/cli-commands/coder/boilerplateCount.d.ts +1 -1
  42. package/umd/src/cli/cli-commands/coder/generate-boilerplates.d.ts +1 -1
  43. package/umd/src/cli/cli-commands/common/{harness/$askForHarnessInstallationApproval.d.ts → npm/$askForNpmPackageInstallationApproval.d.ts} +2 -2
  44. package/umd/src/cli/cli-commands/common/{harness/$resolveLatestHarnessVersion.d.ts → npm/$resolveLatestNpmPackageVersion.d.ts} +2 -3
  45. package/umd/src/cli/cli-commands/common/npm/$resolveLatestNpmPackageVersion.test.d.ts +1 -0
  46. package/umd/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.d.ts +12 -0
  47. package/umd/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.test.d.ts +1 -0
  48. package/umd/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.d.ts +9 -0
  49. package/umd/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.test.d.ts +1 -0
  50. package/umd/src/cli/cli-commands/common/promptbook-cli/$checkPromptbookCliInstallations.d.ts +9 -0
  51. package/umd/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.d.ts +14 -0
  52. package/umd/src/cli/cli-commands/common/promptbook-cli/$ensurePromptbookCliInstallations.test.d.ts +1 -0
  53. package/umd/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.d.ts +12 -0
  54. package/umd/src/cli/cli-commands/common/promptbook-cli/$resolvePromptbookCliInstallations.test.d.ts +1 -0
  55. package/umd/src/cli/cli-commands/common/promptbook-cli/$updatePromptbookCliInstallation.d.ts +10 -0
  56. package/umd/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallation.d.ts +39 -0
  57. package/umd/src/cli/cli-commands/common/promptbook-cli/PromptbookCliInstallationStatus.d.ts +26 -0
  58. package/umd/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.d.ts +7 -0
  59. package/umd/src/cli/cli-commands/common/promptbook-cli/buildPromptbookCliInstallCommand.test.d.ts +1 -0
  60. package/umd/src/cli/cli-commands/common/promptbook-cli/formatPromptbookCliInstallationWarning.d.ts +7 -0
  61. package/umd/src/utils/agent-message-runtime/resolveAgentMessageRuntimeActivity.d.ts +3 -3
  62. package/umd/src/utils/agents/terminalAgentAvatarVisual.d.ts +5 -2
  63. package/umd/src/utils/ascii-art/convertImageDataToAsciiArt.d.ts +6 -0
  64. package/umd/src/utils/ascii-art/createAnsiColorCode.d.ts +46 -0
  65. package/umd/src/utils/misc/debounce.d.ts +4 -2
  66. package/umd/src/utils/misc/debounce.test.d.ts +1 -0
  67. package/umd/src/version.d.ts +1 -1
  68. package/esm/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.d.ts +0 -11
  69. package/esm/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.d.ts +0 -9
  70. package/umd/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.d.ts +0 -11
  71. package/umd/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.d.ts +0 -9
  72. /package/esm/src/{cli/cli-commands/common/harness/extractHarnessVersionFromOutput.test.d.ts → avatars/renderAvatarVisualTerminalText.test.d.ts} +0 -0
  73. /package/esm/src/cli/cli-commands/common/{harness/isHarnessVersionOutdated.test.d.ts → npm/$resolveLatestNpmPackageVersion.test.d.ts} +0 -0
  74. /package/{umd/src/cli/cli-commands/common/harness/extractHarnessVersionFromOutput.test.d.ts → esm/src/cli/cli-commands/common/npm/extractNpmPackageVersionFromOutput.test.d.ts} +0 -0
  75. /package/{umd/src/cli/cli-commands/common/harness/isHarnessVersionOutdated.test.d.ts → esm/src/cli/cli-commands/common/npm/isNpmPackageVersionOutdated.test.d.ts} +0 -0
package/esm/index.es.js CHANGED
@@ -26,7 +26,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
26
26
  * @generated
27
27
  * @see https://github.com/webgptorg/promptbook
28
28
  */
29
- const PROMPTBOOK_ENGINE_VERSION = '0.114.0-5';
29
+ const PROMPTBOOK_ENGINE_VERSION = '0.114.0-8';
30
30
  /**
31
31
  * TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
32
32
  * Note: [💞] Ignore a discrepancy between file name and entity name
@@ -11036,6 +11036,13 @@ function darken(amount) {
11036
11036
  }
11037
11037
 
11038
11038
  /* eslint-disable no-magic-numbers */
11039
+ // Note: [💞] Ignore a discrepancy between file name and entity name
11040
+ /**
11041
+ * Default square size used by avatar renderers.
11042
+ *
11043
+ * @private utility of the avatar rendering system
11044
+ */
11045
+ const DEFAULT_AVATAR_SIZE = 192;
11039
11046
  /**
11040
11047
  * Corner radius ratio used for the common rounded card frame.
11041
11048
  *
@@ -11406,6 +11413,15 @@ const OUTLINE_GLYPHS = ['#', '%', '@'];
11406
11413
  * @private helper of `asciiOctopusAvatarVisual`
11407
11414
  */
11408
11415
  const ATMOSPHERE_GLYPHS = ['.', ':', "'", '`'];
11416
+ /**
11417
+ * Coordinate space the octopus layout is generated in when it is painted into a terminal.
11418
+ *
11419
+ * The terminal renderer has its own character grid, so the geometry only needs one stable
11420
+ * square coordinate space which the grid is then sampled from.
11421
+ *
11422
+ * @private helper of `asciiOctopusAvatarVisual`
11423
+ */
11424
+ const TERMINAL_ASCII_OCTOPUS_LAYOUT_SIZE = DEFAULT_AVATAR_SIZE;
11409
11425
  /**
11410
11426
  * AsciiOctopus avatar visual.
11411
11427
  *
@@ -11422,41 +11438,115 @@ const asciiOctopusAvatarVisual = {
11422
11438
  const staticRandom = createRandom('ascii-octopus-static');
11423
11439
  const gridMetrics = createAsciiGridMetrics(size, gridRandom);
11424
11440
  const layout = createAsciiOctopusLayout(size, timeMs, createRandom, staticRandom, interaction);
11441
+ const glyphGrid = createAsciiOctopusGlyphGrid({
11442
+ sampleGrid: gridMetrics,
11443
+ layout,
11444
+ palette,
11445
+ cellRandom: createRandom('ascii-octopus-cells'),
11446
+ timeMs,
11447
+ });
11425
11448
  drawAvatarFrame(context, size, palette);
11426
11449
  drawAsciiBackdrop(context, size, palette, layout, timeMs);
11427
11450
  context.save();
11428
11451
  context.font = `600 ${gridMetrics.fontSize}px monospace`;
11429
11452
  context.textAlign = 'center';
11430
11453
  context.textBaseline = 'middle';
11431
- // The ASCII renderer samples the morphing octopus field on a low-resolution grid so the shape stays organic
11432
- // while the glyph layout remains deterministic for the same avatar input.
11433
- const cellRandom = createRandom('ascii-octopus-cells');
11434
11454
  for (let rowIndex = 0; rowIndex < gridMetrics.rowCount; rowIndex++) {
11435
11455
  for (let columnIndex = 0; columnIndex < gridMetrics.columnCount; columnIndex++) {
11436
- const point = {
11437
- x: gridMetrics.offsetX + columnIndex * gridMetrics.cellWidth,
11438
- y: gridMetrics.offsetY + rowIndex * gridMetrics.cellHeight,
11439
- };
11440
- const noise = cellRandom();
11441
- const glyphDescriptor = resolveAsciiGlyph({
11442
- point,
11443
- layout,
11444
- palette,
11445
- cellWidth: gridMetrics.cellWidth,
11446
- cellHeight: gridMetrics.cellHeight,
11447
- noise,
11448
- timeMs,
11449
- });
11456
+ const glyphDescriptor = glyphGrid[rowIndex][columnIndex];
11450
11457
  if (!glyphDescriptor) {
11451
11458
  continue;
11452
11459
  }
11460
+ const point = resolveAsciiSampleGridPoint(gridMetrics, columnIndex, rowIndex);
11453
11461
  context.fillStyle = glyphDescriptor.color;
11454
11462
  context.fillText(glyphDescriptor.character, point.x, point.y);
11455
11463
  }
11456
11464
  }
11457
11465
  context.restore();
11458
11466
  },
11467
+ renderTerminalText({ columns, rows, palette, createRandom, timeMs, interaction }) {
11468
+ const staticRandom = createRandom('ascii-octopus-static');
11469
+ const layout = createAsciiOctopusLayout(TERMINAL_ASCII_OCTOPUS_LAYOUT_SIZE, timeMs, createRandom, staticRandom, interaction);
11470
+ return createAsciiOctopusGlyphGrid({
11471
+ sampleGrid: createAsciiTerminalSampleGrid(columns, rows),
11472
+ layout,
11473
+ palette,
11474
+ cellRandom: createRandom('ascii-octopus-cells'),
11475
+ timeMs,
11476
+ });
11477
+ },
11459
11478
  };
11479
+ /**
11480
+ * Resolves the geometry point sampled for one cell of the grid.
11481
+ *
11482
+ * @param sampleGrid Character-cell sampling grid.
11483
+ * @param columnIndex Zero-based cell column.
11484
+ * @param rowIndex Zero-based cell row.
11485
+ * @returns Sampled point in the octopus coordinate space.
11486
+ *
11487
+ * @private helper of `asciiOctopusAvatarVisual`
11488
+ */
11489
+ function resolveAsciiSampleGridPoint(sampleGrid, columnIndex, rowIndex) {
11490
+ return {
11491
+ x: sampleGrid.offsetX + columnIndex * sampleGrid.cellWidth,
11492
+ y: sampleGrid.offsetY + rowIndex * sampleGrid.cellHeight,
11493
+ };
11494
+ }
11495
+ /**
11496
+ * Builds the sampling grid used when the octopus is painted straight into terminal character cells.
11497
+ *
11498
+ * @param columns Available terminal columns.
11499
+ * @param rows Available terminal rows.
11500
+ * @returns Character-cell sampling grid covering the whole octopus coordinate space.
11501
+ *
11502
+ * @private helper of `asciiOctopusAvatarVisual`
11503
+ */
11504
+ function createAsciiTerminalSampleGrid(columns, rows) {
11505
+ const cellWidth = TERMINAL_ASCII_OCTOPUS_LAYOUT_SIZE / columns;
11506
+ const cellHeight = TERMINAL_ASCII_OCTOPUS_LAYOUT_SIZE / rows;
11507
+ return {
11508
+ cellWidth,
11509
+ cellHeight,
11510
+ columnCount: columns,
11511
+ rowCount: rows,
11512
+ offsetX: cellWidth / 2,
11513
+ offsetY: cellHeight / 2,
11514
+ };
11515
+ }
11516
+ /**
11517
+ * Samples the morphing octopus field into one deterministic grid of ASCII glyphs.
11518
+ *
11519
+ * The field is sampled on a low-resolution grid so the shape stays organic while the glyph
11520
+ * layout remains deterministic for the same avatar input. Both the canvas visual and the
11521
+ * terminal visual share this single sampling pass so they always describe the same octopus.
11522
+ *
11523
+ * @param options Sampling grid, prepared octopus layout, palette, per-cell noise, and animation time.
11524
+ * @returns Resolved glyph of every sampled cell, where `null` means an empty cell.
11525
+ *
11526
+ * @private helper of `asciiOctopusAvatarVisual`
11527
+ */
11528
+ function createAsciiOctopusGlyphGrid(options) {
11529
+ const { sampleGrid, layout, palette, cellRandom, timeMs } = options;
11530
+ const glyphGrid = [];
11531
+ for (let rowIndex = 0; rowIndex < sampleGrid.rowCount; rowIndex++) {
11532
+ const glyphRow = [];
11533
+ for (let columnIndex = 0; columnIndex < sampleGrid.columnCount; columnIndex++) {
11534
+ const point = resolveAsciiSampleGridPoint(sampleGrid, columnIndex, rowIndex);
11535
+ const noise = cellRandom();
11536
+ glyphRow.push(resolveAsciiGlyph({
11537
+ point,
11538
+ layout,
11539
+ palette,
11540
+ cellWidth: sampleGrid.cellWidth,
11541
+ cellHeight: sampleGrid.cellHeight,
11542
+ noise,
11543
+ timeMs,
11544
+ }));
11545
+ }
11546
+ glyphGrid.push(glyphRow);
11547
+ }
11548
+ return glyphGrid;
11549
+ }
11460
11550
  /**
11461
11551
  * Draws the dark terminal-like glow behind the ASCII octopus.
11462
11552
  *
@@ -27106,12 +27196,7 @@ function createFocusedCommitmentExampleSource(source, group) {
27106
27196
  const parsedSource = parseAgentSourceWithCommitments(source);
27107
27197
  const commitmentTypes = new Set([group.primary.type, ...group.aliases]);
27108
27198
  const isOpenClosedCommitmentFamily = commitmentTypes.has(OPEN_COMMITMENT_TYPE) && commitmentTypes.has(CLOSED_COMMITMENT_TYPE);
27109
- const allowedCommitmentTypes = new Set([
27110
- group.primary.type,
27111
- ...group.aliases,
27112
- 'GOAL',
27113
- CLOSED_COMMITMENT_TYPE,
27114
- ]);
27199
+ const allowedCommitmentTypes = new Set([group.primary.type, ...group.aliases, 'GOAL', CLOSED_COMMITMENT_TYPE]);
27115
27200
  const canonicalTypeByCommitmentType = createCanonicalCommitmentTypeByCommitmentType(group, isOpenClosedCommitmentFamily);
27116
27201
  const focusedCommitments = parsedSource.commitments
27117
27202
  .filter((commitment) => allowedCommitmentTypes.has(commitment.type))
@@ -27218,9 +27303,7 @@ function finalizeFocusedCommitmentExampleSource(agentName, focusedCommitments) {
27218
27303
  if (!isClosedCommitmentIncluded && !isOpenCommitmentIncluded) {
27219
27304
  normalizedFocusedCommitments.push(CLOSED_COMMITMENT_TYPE);
27220
27305
  }
27221
- return [agentName, ...normalizedFocusedCommitments]
27222
- .filter((line) => Boolean(line))
27223
- .join('\n\n');
27306
+ return [agentName, ...normalizedFocusedCommitments].filter((line) => Boolean(line)).join('\n\n');
27224
27307
  }
27225
27308
  /**
27226
27309
  * Keeps an example title unless the parser interpreted a commitment-only
@@ -27512,9 +27595,7 @@ function createStandaloneBookLanguageMarkdown(options = {}) {
27512
27595
 
27513
27596
  ${block(dictionary.tutorialSections.checklistBody)}
27514
27597
 
27515
- ${block(isLowLevelCommitmentsIncluded
27516
- ? renderLowLevelCommitmentsChapter(lowLevelCommitments, dictionary)
27517
- : '')}
27598
+ ${block(isLowLevelCommitmentsIncluded ? renderLowLevelCommitmentsChapter(lowLevelCommitments, dictionary) : '')}
27518
27599
 
27519
27600
  ---
27520
27601
 
@@ -29560,8 +29641,8 @@ const formatCommandParser = {
29560
29641
  */
29561
29642
  $applyToTaskJson(command, $taskJson) {
29562
29643
  if ($taskJson.format !== undefined && command.format !== $taskJson.format) {
29563
- throw new ParseError(`Format format is already defined to "${$taskJson.format}".
29564
- Now you try to redefine it by "${command.format}"`);
29644
+ throw new ParseError(spaceTrim$1(`Format format is already defined to "${$taskJson.format}".
29645
+ Now you try to redefine it by "${command.format}"`));
29565
29646
  }
29566
29647
  $taskJson.format = command.format;
29567
29648
  },
@@ -34871,28 +34952,28 @@ function parseToolExecutionEnvelope(rawValue) {
34871
34952
  */
34872
34953
  function buildToolInvocationScript(options) {
34873
34954
  const { functionName, functionArgsExpression } = options;
34874
- return `
34875
- const args = ${functionArgsExpression};
34876
- const runtimeContextRaw =
34877
- typeof ${TOOL_RUNTIME_CONTEXT_PARAMETER} === 'undefined'
34878
- ? undefined
34879
- : ${TOOL_RUNTIME_CONTEXT_PARAMETER};
34955
+ return spaceTrim$1((block) => `
34956
+ const args = ${block(functionArgsExpression)};
34957
+ const runtimeContextRaw =
34958
+ typeof ${TOOL_RUNTIME_CONTEXT_PARAMETER} === 'undefined'
34959
+ ? undefined
34960
+ : ${TOOL_RUNTIME_CONTEXT_PARAMETER};
34880
34961
 
34881
- if (runtimeContextRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
34882
- args.${TOOL_RUNTIME_CONTEXT_ARGUMENT} = runtimeContextRaw;
34883
- }
34962
+ if (runtimeContextRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
34963
+ args.${TOOL_RUNTIME_CONTEXT_ARGUMENT} = runtimeContextRaw;
34964
+ }
34884
34965
 
34885
- const toolProgressTokenRaw =
34886
- typeof ${TOOL_PROGRESS_TOKEN_PARAMETER} === 'undefined'
34887
- ? undefined
34888
- : ${TOOL_PROGRESS_TOKEN_PARAMETER};
34966
+ const toolProgressTokenRaw =
34967
+ typeof ${TOOL_PROGRESS_TOKEN_PARAMETER} === 'undefined'
34968
+ ? undefined
34969
+ : ${TOOL_PROGRESS_TOKEN_PARAMETER};
34889
34970
 
34890
- if (toolProgressTokenRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
34891
- args.${TOOL_PROGRESS_TOKEN_ARGUMENT} = toolProgressTokenRaw;
34892
- }
34971
+ if (toolProgressTokenRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
34972
+ args.${TOOL_PROGRESS_TOKEN_ARGUMENT} = toolProgressTokenRaw;
34973
+ }
34893
34974
 
34894
- return await ${functionName}(args);
34895
- `;
34975
+ return await ${functionName}(args);
34976
+ `);
34896
34977
  }
34897
34978
 
34898
34979
  /**