@promptbook/core 0.114.0-5 → 0.114.0-7

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/umd/index.umd.js CHANGED
@@ -28,7 +28,7 @@
28
28
  * @generated
29
29
  * @see https://github.com/webgptorg/promptbook
30
30
  */
31
- const PROMPTBOOK_ENGINE_VERSION = '0.114.0-5';
31
+ const PROMPTBOOK_ENGINE_VERSION = '0.114.0-7';
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
@@ -11038,6 +11038,13 @@
11038
11038
  }
11039
11039
 
11040
11040
  /* eslint-disable no-magic-numbers */
11041
+ // Note: [💞] Ignore a discrepancy between file name and entity name
11042
+ /**
11043
+ * Default square size used by avatar renderers.
11044
+ *
11045
+ * @private utility of the avatar rendering system
11046
+ */
11047
+ const DEFAULT_AVATAR_SIZE = 192;
11041
11048
  /**
11042
11049
  * Corner radius ratio used for the common rounded card frame.
11043
11050
  *
@@ -11408,6 +11415,15 @@
11408
11415
  * @private helper of `asciiOctopusAvatarVisual`
11409
11416
  */
11410
11417
  const ATMOSPHERE_GLYPHS = ['.', ':', "'", '`'];
11418
+ /**
11419
+ * Coordinate space the octopus layout is generated in when it is painted into a terminal.
11420
+ *
11421
+ * The terminal renderer has its own character grid, so the geometry only needs one stable
11422
+ * square coordinate space which the grid is then sampled from.
11423
+ *
11424
+ * @private helper of `asciiOctopusAvatarVisual`
11425
+ */
11426
+ const TERMINAL_ASCII_OCTOPUS_LAYOUT_SIZE = DEFAULT_AVATAR_SIZE;
11411
11427
  /**
11412
11428
  * AsciiOctopus avatar visual.
11413
11429
  *
@@ -11424,41 +11440,115 @@
11424
11440
  const staticRandom = createRandom('ascii-octopus-static');
11425
11441
  const gridMetrics = createAsciiGridMetrics(size, gridRandom);
11426
11442
  const layout = createAsciiOctopusLayout(size, timeMs, createRandom, staticRandom, interaction);
11443
+ const glyphGrid = createAsciiOctopusGlyphGrid({
11444
+ sampleGrid: gridMetrics,
11445
+ layout,
11446
+ palette,
11447
+ cellRandom: createRandom('ascii-octopus-cells'),
11448
+ timeMs,
11449
+ });
11427
11450
  drawAvatarFrame(context, size, palette);
11428
11451
  drawAsciiBackdrop(context, size, palette, layout, timeMs);
11429
11452
  context.save();
11430
11453
  context.font = `600 ${gridMetrics.fontSize}px monospace`;
11431
11454
  context.textAlign = 'center';
11432
11455
  context.textBaseline = 'middle';
11433
- // The ASCII renderer samples the morphing octopus field on a low-resolution grid so the shape stays organic
11434
- // while the glyph layout remains deterministic for the same avatar input.
11435
- const cellRandom = createRandom('ascii-octopus-cells');
11436
11456
  for (let rowIndex = 0; rowIndex < gridMetrics.rowCount; rowIndex++) {
11437
11457
  for (let columnIndex = 0; columnIndex < gridMetrics.columnCount; columnIndex++) {
11438
- const point = {
11439
- x: gridMetrics.offsetX + columnIndex * gridMetrics.cellWidth,
11440
- y: gridMetrics.offsetY + rowIndex * gridMetrics.cellHeight,
11441
- };
11442
- const noise = cellRandom();
11443
- const glyphDescriptor = resolveAsciiGlyph({
11444
- point,
11445
- layout,
11446
- palette,
11447
- cellWidth: gridMetrics.cellWidth,
11448
- cellHeight: gridMetrics.cellHeight,
11449
- noise,
11450
- timeMs,
11451
- });
11458
+ const glyphDescriptor = glyphGrid[rowIndex][columnIndex];
11452
11459
  if (!glyphDescriptor) {
11453
11460
  continue;
11454
11461
  }
11462
+ const point = resolveAsciiSampleGridPoint(gridMetrics, columnIndex, rowIndex);
11455
11463
  context.fillStyle = glyphDescriptor.color;
11456
11464
  context.fillText(glyphDescriptor.character, point.x, point.y);
11457
11465
  }
11458
11466
  }
11459
11467
  context.restore();
11460
11468
  },
11469
+ renderTerminalText({ columns, rows, palette, createRandom, timeMs, interaction }) {
11470
+ const staticRandom = createRandom('ascii-octopus-static');
11471
+ const layout = createAsciiOctopusLayout(TERMINAL_ASCII_OCTOPUS_LAYOUT_SIZE, timeMs, createRandom, staticRandom, interaction);
11472
+ return createAsciiOctopusGlyphGrid({
11473
+ sampleGrid: createAsciiTerminalSampleGrid(columns, rows),
11474
+ layout,
11475
+ palette,
11476
+ cellRandom: createRandom('ascii-octopus-cells'),
11477
+ timeMs,
11478
+ });
11479
+ },
11461
11480
  };
11481
+ /**
11482
+ * Resolves the geometry point sampled for one cell of the grid.
11483
+ *
11484
+ * @param sampleGrid Character-cell sampling grid.
11485
+ * @param columnIndex Zero-based cell column.
11486
+ * @param rowIndex Zero-based cell row.
11487
+ * @returns Sampled point in the octopus coordinate space.
11488
+ *
11489
+ * @private helper of `asciiOctopusAvatarVisual`
11490
+ */
11491
+ function resolveAsciiSampleGridPoint(sampleGrid, columnIndex, rowIndex) {
11492
+ return {
11493
+ x: sampleGrid.offsetX + columnIndex * sampleGrid.cellWidth,
11494
+ y: sampleGrid.offsetY + rowIndex * sampleGrid.cellHeight,
11495
+ };
11496
+ }
11497
+ /**
11498
+ * Builds the sampling grid used when the octopus is painted straight into terminal character cells.
11499
+ *
11500
+ * @param columns Available terminal columns.
11501
+ * @param rows Available terminal rows.
11502
+ * @returns Character-cell sampling grid covering the whole octopus coordinate space.
11503
+ *
11504
+ * @private helper of `asciiOctopusAvatarVisual`
11505
+ */
11506
+ function createAsciiTerminalSampleGrid(columns, rows) {
11507
+ const cellWidth = TERMINAL_ASCII_OCTOPUS_LAYOUT_SIZE / columns;
11508
+ const cellHeight = TERMINAL_ASCII_OCTOPUS_LAYOUT_SIZE / rows;
11509
+ return {
11510
+ cellWidth,
11511
+ cellHeight,
11512
+ columnCount: columns,
11513
+ rowCount: rows,
11514
+ offsetX: cellWidth / 2,
11515
+ offsetY: cellHeight / 2,
11516
+ };
11517
+ }
11518
+ /**
11519
+ * Samples the morphing octopus field into one deterministic grid of ASCII glyphs.
11520
+ *
11521
+ * The field is sampled on a low-resolution grid so the shape stays organic while the glyph
11522
+ * layout remains deterministic for the same avatar input. Both the canvas visual and the
11523
+ * terminal visual share this single sampling pass so they always describe the same octopus.
11524
+ *
11525
+ * @param options Sampling grid, prepared octopus layout, palette, per-cell noise, and animation time.
11526
+ * @returns Resolved glyph of every sampled cell, where `null` means an empty cell.
11527
+ *
11528
+ * @private helper of `asciiOctopusAvatarVisual`
11529
+ */
11530
+ function createAsciiOctopusGlyphGrid(options) {
11531
+ const { sampleGrid, layout, palette, cellRandom, timeMs } = options;
11532
+ const glyphGrid = [];
11533
+ for (let rowIndex = 0; rowIndex < sampleGrid.rowCount; rowIndex++) {
11534
+ const glyphRow = [];
11535
+ for (let columnIndex = 0; columnIndex < sampleGrid.columnCount; columnIndex++) {
11536
+ const point = resolveAsciiSampleGridPoint(sampleGrid, columnIndex, rowIndex);
11537
+ const noise = cellRandom();
11538
+ glyphRow.push(resolveAsciiGlyph({
11539
+ point,
11540
+ layout,
11541
+ palette,
11542
+ cellWidth: sampleGrid.cellWidth,
11543
+ cellHeight: sampleGrid.cellHeight,
11544
+ noise,
11545
+ timeMs,
11546
+ }));
11547
+ }
11548
+ glyphGrid.push(glyphRow);
11549
+ }
11550
+ return glyphGrid;
11551
+ }
11462
11552
  /**
11463
11553
  * Draws the dark terminal-like glow behind the ASCII octopus.
11464
11554
  *
@@ -27108,12 +27198,7 @@
27108
27198
  const parsedSource = parseAgentSourceWithCommitments(source);
27109
27199
  const commitmentTypes = new Set([group.primary.type, ...group.aliases]);
27110
27200
  const isOpenClosedCommitmentFamily = commitmentTypes.has(OPEN_COMMITMENT_TYPE) && commitmentTypes.has(CLOSED_COMMITMENT_TYPE);
27111
- const allowedCommitmentTypes = new Set([
27112
- group.primary.type,
27113
- ...group.aliases,
27114
- 'GOAL',
27115
- CLOSED_COMMITMENT_TYPE,
27116
- ]);
27201
+ const allowedCommitmentTypes = new Set([group.primary.type, ...group.aliases, 'GOAL', CLOSED_COMMITMENT_TYPE]);
27117
27202
  const canonicalTypeByCommitmentType = createCanonicalCommitmentTypeByCommitmentType(group, isOpenClosedCommitmentFamily);
27118
27203
  const focusedCommitments = parsedSource.commitments
27119
27204
  .filter((commitment) => allowedCommitmentTypes.has(commitment.type))
@@ -27220,9 +27305,7 @@
27220
27305
  if (!isClosedCommitmentIncluded && !isOpenCommitmentIncluded) {
27221
27306
  normalizedFocusedCommitments.push(CLOSED_COMMITMENT_TYPE);
27222
27307
  }
27223
- return [agentName, ...normalizedFocusedCommitments]
27224
- .filter((line) => Boolean(line))
27225
- .join('\n\n');
27308
+ return [agentName, ...normalizedFocusedCommitments].filter((line) => Boolean(line)).join('\n\n');
27226
27309
  }
27227
27310
  /**
27228
27311
  * Keeps an example title unless the parser interpreted a commitment-only
@@ -27514,9 +27597,7 @@
27514
27597
 
27515
27598
  ${block(dictionary.tutorialSections.checklistBody)}
27516
27599
 
27517
- ${block(isLowLevelCommitmentsIncluded
27518
- ? renderLowLevelCommitmentsChapter(lowLevelCommitments, dictionary)
27519
- : '')}
27600
+ ${block(isLowLevelCommitmentsIncluded ? renderLowLevelCommitmentsChapter(lowLevelCommitments, dictionary) : '')}
27520
27601
 
27521
27602
  ---
27522
27603
 
@@ -29562,8 +29643,8 @@
29562
29643
  */
29563
29644
  $applyToTaskJson(command, $taskJson) {
29564
29645
  if ($taskJson.format !== undefined && command.format !== $taskJson.format) {
29565
- throw new ParseError(`Format format is already defined to "${$taskJson.format}".
29566
- Now you try to redefine it by "${command.format}"`);
29646
+ throw new ParseError(spacetrim.spaceTrim(`Format format is already defined to "${$taskJson.format}".
29647
+ Now you try to redefine it by "${command.format}"`));
29567
29648
  }
29568
29649
  $taskJson.format = command.format;
29569
29650
  },
@@ -34873,28 +34954,28 @@
34873
34954
  */
34874
34955
  function buildToolInvocationScript(options) {
34875
34956
  const { functionName, functionArgsExpression } = options;
34876
- return `
34877
- const args = ${functionArgsExpression};
34878
- const runtimeContextRaw =
34879
- typeof ${TOOL_RUNTIME_CONTEXT_PARAMETER} === 'undefined'
34880
- ? undefined
34881
- : ${TOOL_RUNTIME_CONTEXT_PARAMETER};
34957
+ return spacetrim.spaceTrim((block) => `
34958
+ const args = ${block(functionArgsExpression)};
34959
+ const runtimeContextRaw =
34960
+ typeof ${TOOL_RUNTIME_CONTEXT_PARAMETER} === 'undefined'
34961
+ ? undefined
34962
+ : ${TOOL_RUNTIME_CONTEXT_PARAMETER};
34882
34963
 
34883
- if (runtimeContextRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
34884
- args.${TOOL_RUNTIME_CONTEXT_ARGUMENT} = runtimeContextRaw;
34885
- }
34964
+ if (runtimeContextRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
34965
+ args.${TOOL_RUNTIME_CONTEXT_ARGUMENT} = runtimeContextRaw;
34966
+ }
34886
34967
 
34887
- const toolProgressTokenRaw =
34888
- typeof ${TOOL_PROGRESS_TOKEN_PARAMETER} === 'undefined'
34889
- ? undefined
34890
- : ${TOOL_PROGRESS_TOKEN_PARAMETER};
34968
+ const toolProgressTokenRaw =
34969
+ typeof ${TOOL_PROGRESS_TOKEN_PARAMETER} === 'undefined'
34970
+ ? undefined
34971
+ : ${TOOL_PROGRESS_TOKEN_PARAMETER};
34891
34972
 
34892
- if (toolProgressTokenRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
34893
- args.${TOOL_PROGRESS_TOKEN_ARGUMENT} = toolProgressTokenRaw;
34894
- }
34973
+ if (toolProgressTokenRaw !== undefined && args && typeof args === 'object' && !Array.isArray(args)) {
34974
+ args.${TOOL_PROGRESS_TOKEN_ARGUMENT} = toolProgressTokenRaw;
34975
+ }
34895
34976
 
34896
- return await ${functionName}(args);
34897
- `;
34977
+ return await ${functionName}(args);
34978
+ `);
34898
34979
  }
34899
34980
 
34900
34981
  /**