@promptbook/cli 0.112.0 → 0.113.0-1

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 (109) hide show
  1. package/README.md +45 -29
  2. package/agents/default/developer.book +2 -1
  3. package/apps/agents-server/next.config.ts +21 -0
  4. package/apps/agents-server/src/app/admin/limits/LimitsClient.tsx +1 -1
  5. package/apps/agents-server/src/app/admin/task-manager/TaskManagerTaskRow.tsx +7 -2
  6. package/apps/agents-server/src/app/admin/update/UpdateClient.tsx +52 -33
  7. package/apps/agents-server/src/app/api/agent-folders/[folderId]/visibility/route.ts +19 -7
  8. package/apps/agents-server/src/app/api/agents/[agentName]/route.ts +8 -18
  9. package/apps/agents-server/src/app/api/internal/agent-runner-limits/route.ts +1 -1
  10. package/apps/agents-server/src/app/api/page-preview/check/route.ts +5 -20
  11. package/apps/agents-server/src/app/api/page-preview/interact/route.ts +179 -0
  12. package/apps/agents-server/src/app/api/page-preview/live/route.ts +67 -0
  13. package/apps/agents-server/src/app/api/page-preview/screenshot/route.ts +13 -21
  14. package/apps/agents-server/src/app/api/v1/agents/[agentId]/route.ts +13 -8
  15. package/apps/agents-server/src/components/AgentProfile/AgentCapabilityChips.tsx +39 -5
  16. package/apps/agents-server/src/components/Homepage/AgentCard.tsx +7 -1
  17. package/apps/agents-server/src/components/Homepage/AgentsList.tsx +3 -0
  18. package/apps/agents-server/src/components/Homepage/AgentsListHeader.tsx +41 -0
  19. package/apps/agents-server/src/components/Homepage/hiddenFolders.ts +104 -0
  20. package/apps/agents-server/src/components/Homepage/useAgentsListQueryState.ts +35 -0
  21. package/apps/agents-server/src/components/Homepage/useAgentsListState.ts +24 -4
  22. package/apps/agents-server/src/constants/chatVisualMode.ts +1 -1
  23. package/apps/agents-server/src/constants/serverLimits.ts +19 -0
  24. package/apps/agents-server/src/constants/themeMode.ts +1 -1
  25. package/apps/agents-server/src/database/migrations/2026-05-2600-default-theme.sql +2 -2
  26. package/apps/agents-server/src/database/seedCoreAgents.ts +0 -2
  27. package/apps/agents-server/src/database/seedDefaultAgents.ts +0 -2
  28. package/apps/agents-server/src/tools/agent_progress.ts +4 -10
  29. package/apps/agents-server/src/utils/agentVisibility.ts +25 -62
  30. package/apps/agents-server/src/utils/chatTasksAdmin.ts +3 -1
  31. package/apps/agents-server/src/utils/createAgentWithDefaultVisibility.ts +3 -1
  32. package/apps/agents-server/src/utils/externalChatRunner/processExternalUserChatJob.ts +9 -17
  33. package/apps/agents-server/src/utils/getAdminChatTasksResponse/mapVpsSelfUpdateJobToAdminChatTask.ts +84 -0
  34. package/apps/agents-server/src/utils/getAdminChatTasksResponse.ts +195 -5
  35. package/apps/agents-server/src/utils/localChatRunner/LocalUserChatJobMetadata.ts +15 -5
  36. package/apps/agents-server/src/utils/localChatRunner/processLocalUserChatJob.ts +17 -26
  37. package/apps/agents-server/src/utils/pagePreview/livePagePreviewSessions.ts +365 -0
  38. package/apps/agents-server/src/utils/pagePreview/resolvePagePreviewRequestUrl.ts +74 -0
  39. package/apps/agents-server/src/utils/serverLimits.ts +2 -0
  40. package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerCoreAgents.ts +2 -2
  41. package/apps/agents-server/src/utils/serverManagement/createManagedServer/seedServerDefaultAgents.ts +1 -1
  42. package/apps/agents-server/src/utils/userChat/createUserChatHarnessProgressCard.ts +0 -6
  43. package/apps/agents-server/src/utils/userChat/createUserChatRunnerProgressCard.ts +0 -6
  44. package/apps/agents-server/src/utils/userChat/userChatMessageLifecycle.ts +69 -0
  45. package/apps/agents-server/src/utils/userChat/userChatProgressCard.ts +0 -6
  46. package/apps/agents-server/src/utils/vpsSelfUpdate.ts +150 -24
  47. package/esm/apps/agents-server/src/constants/serverLimits.d.ts +17 -0
  48. package/esm/index.es.js +581 -93
  49. package/esm/index.es.js.map +1 -1
  50. package/esm/scripts/run-agent-messages/main/runMultipleAgentMessages.d.ts +1 -0
  51. package/esm/scripts/run-agent-messages/main/tickAgentMessages.d.ts +1 -0
  52. package/esm/src/_packages/core.index.d.ts +22 -0
  53. package/esm/src/_packages/types.index.d.ts +2 -0
  54. package/esm/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -0
  55. package/esm/src/book-2.0/agent-source/agentSourceVisibility.d.ts +97 -0
  56. package/esm/src/book-2.0/agent-source/agentSourceVisibility.test.d.ts +1 -0
  57. package/esm/src/book-components/BookEditor/BookEditorMonacoTokenization.d.ts +1 -0
  58. package/esm/src/book-components/Chat/Chat/CitationIframePreview.d.ts +2 -2
  59. package/esm/src/book-components/Chat/utils/livePagePreviewConstants.d.ts +12 -0
  60. package/esm/src/cli/cli-commands/agents-server/buildAgentsServer.d.ts +6 -0
  61. package/esm/src/collection/agent-collection/CreateAgentInput.d.ts +2 -1
  62. package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/prepareAgentSourceForPersistence.d.ts +21 -1
  63. package/esm/src/commitments/META_VISIBILITY/META_VISIBILITY.d.ts +27 -0
  64. package/esm/src/commitments/index.d.ts +2 -1
  65. package/esm/src/version.d.ts +1 -1
  66. package/package.json +1 -1
  67. package/src/_packages/core.index.ts +22 -0
  68. package/src/_packages/types.index.ts +2 -0
  69. package/src/book-2.0/agent-source/AgentBasicInformation.ts +2 -0
  70. package/src/book-2.0/agent-source/agentSourceVisibility.ts +214 -0
  71. package/src/book-2.0/agent-source/parseAgentSource/applyMetaCommitment.ts +17 -0
  72. package/src/book-2.0/book-language-documentation/createStandaloneBookLanguageMarkdown.ts +1 -0
  73. package/src/book-components/BookEditor/BookEditorMonacoTokenization.ts +11 -0
  74. package/src/book-components/BookEditor/useBookEditorMonacoLanguage.ts +7 -3
  75. package/src/book-components/Chat/Chat/Chat.module.css +14 -5
  76. package/src/book-components/Chat/Chat/CitationIframePreview.tsx +197 -22
  77. package/src/book-components/Chat/utils/livePagePreviewConstants.ts +17 -0
  78. package/src/cli/cli-commands/agents-server/buildAgentsServer.ts +144 -16
  79. package/src/cli/cli-commands/agents-server/startAgentsServer.ts +22 -2
  80. package/src/cli/cli-commands/coder/getDefaultCoderPackageJsonScripts.ts +1 -1
  81. package/src/cli/cli-commands/coder/run.ts +30 -0
  82. package/src/collection/agent-collection/CreateAgentInput.ts +10 -5
  83. package/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.ts +7 -3
  84. package/src/collection/agent-collection/constructors/agent-collection-in-supabase/createAgentPersistenceRecords.ts +7 -4
  85. package/src/collection/agent-collection/constructors/agent-collection-in-supabase/prepareAgentSourceForPersistence.ts +44 -8
  86. package/src/commitments/META_VISIBILITY/META_VISIBILITY.ts +78 -0
  87. package/src/commitments/index.ts +2 -0
  88. package/src/other/templates/getTemplatesPipelineCollection.ts +826 -650
  89. package/src/version.ts +2 -2
  90. package/src/versions.txt +2 -0
  91. package/umd/apps/agents-server/src/constants/serverLimits.d.ts +17 -0
  92. package/umd/index.umd.js +581 -93
  93. package/umd/index.umd.js.map +1 -1
  94. package/umd/scripts/run-agent-messages/main/runMultipleAgentMessages.d.ts +1 -0
  95. package/umd/scripts/run-agent-messages/main/tickAgentMessages.d.ts +1 -0
  96. package/umd/src/_packages/core.index.d.ts +22 -0
  97. package/umd/src/_packages/types.index.d.ts +2 -0
  98. package/umd/src/book-2.0/agent-source/AgentBasicInformation.d.ts +2 -0
  99. package/umd/src/book-2.0/agent-source/agentSourceVisibility.d.ts +97 -0
  100. package/umd/src/book-2.0/agent-source/agentSourceVisibility.test.d.ts +1 -0
  101. package/umd/src/book-components/BookEditor/BookEditorMonacoTokenization.d.ts +1 -0
  102. package/umd/src/book-components/Chat/Chat/CitationIframePreview.d.ts +2 -2
  103. package/umd/src/book-components/Chat/utils/livePagePreviewConstants.d.ts +12 -0
  104. package/umd/src/cli/cli-commands/agents-server/buildAgentsServer.d.ts +6 -0
  105. package/umd/src/collection/agent-collection/CreateAgentInput.d.ts +2 -1
  106. package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/prepareAgentSourceForPersistence.d.ts +21 -1
  107. package/umd/src/commitments/META_VISIBILITY/META_VISIBILITY.d.ts +27 -0
  108. package/umd/src/commitments/index.d.ts +2 -1
  109. package/umd/src/version.d.ts +1 -1
@@ -21,7 +21,10 @@ import {
21
21
  type PreparedAgentsServerRuntime,
22
22
  resolveAgentsServerAppPath,
23
23
  } from './buildAgentsServer';
24
- import { DEFAULT_LOCAL_AGENT_RUNNER_MAX_FAILED_ATTEMPTS } from '../../../../apps/agents-server/src/constants/serverLimits';
24
+ import {
25
+ DEFAULT_LOCAL_AGENT_RUNNER_MAX_FAILED_ATTEMPTS,
26
+ DEFAULT_LOCAL_AGENT_RUNNER_MAX_PARALLEL_MESSAGES,
27
+ } from '../../../../apps/agents-server/src/constants/serverLimits';
25
28
 
26
29
  /**
27
30
  * Local worker-pump delay while the Agents Server foreground process stays active.
@@ -206,6 +209,7 @@ type PreparedAgentsServerLaunch = {
206
209
  */
207
210
  type LocalAgentRunnerLimits = {
208
211
  readonly maxFailedAttempts: number;
212
+ readonly maxParallelMessages: number;
209
213
  };
210
214
 
211
215
  /**
@@ -537,6 +541,7 @@ function createLocalAgentRunOptions(
537
541
  autoPull: false,
538
542
  autoClone: false,
539
543
  maxMessageProcessingFailures: localAgentRunnerLimits.maxFailedAttempts,
544
+ maxParallelMessages: localAgentRunnerLimits.maxParallelMessages,
540
545
  };
541
546
  }
542
547
 
@@ -557,7 +562,7 @@ async function waitForLocalAgentRunnerLimits(options: {
557
562
  const limits = await fetchLocalAgentRunnerLimits(options);
558
563
  logRunnerEvent(
559
564
  options.logStreams.runner,
560
- `Local agent runner max failed attempts: ${limits.maxFailedAttempts}.`,
565
+ `Local agent runner limits: ${limits.maxFailedAttempts} failed attempt(s), ${limits.maxParallelMessages} parallel message(s).`,
561
566
  );
562
567
  return limits;
563
568
  } catch (error) {
@@ -569,6 +574,7 @@ async function waitForLocalAgentRunnerLimits(options: {
569
574
  if (!options.state.isContinuing) {
570
575
  return {
571
576
  maxFailedAttempts: DEFAULT_LOCAL_AGENT_RUNNER_MAX_FAILED_ATTEMPTS,
577
+ maxParallelMessages: DEFAULT_LOCAL_AGENT_RUNNER_MAX_PARALLEL_MESSAGES,
572
578
  };
573
579
  }
574
580
 
@@ -604,6 +610,7 @@ async function fetchLocalAgentRunnerLimits(options: {
604
610
  const payload = (await response.json()) as Partial<LocalAgentRunnerLimits>;
605
611
  return {
606
612
  maxFailedAttempts: normalizeLocalAgentRunnerMaxFailedAttempts(payload.maxFailedAttempts),
613
+ maxParallelMessages: normalizeLocalAgentRunnerMaxParallelMessages(payload.maxParallelMessages),
607
614
  };
608
615
  }
609
616
 
@@ -620,6 +627,19 @@ function normalizeLocalAgentRunnerMaxFailedAttempts(rawValue: unknown): number {
620
627
  return Math.floor(parsedValue);
621
628
  }
622
629
 
630
+ /**
631
+ * Normalizes the local runner parallel message cap returned by the internal server route.
632
+ */
633
+ function normalizeLocalAgentRunnerMaxParallelMessages(rawValue: unknown): number {
634
+ const parsedValue = Number(rawValue);
635
+
636
+ if (!Number.isFinite(parsedValue) || parsedValue <= 0) {
637
+ return DEFAULT_LOCAL_AGENT_RUNNER_MAX_PARALLEL_MESSAGES;
638
+ }
639
+
640
+ return Math.floor(parsedValue);
641
+ }
642
+
623
643
  /**
624
644
  * Starts periodic internal worker calls that queue and reconcile local message-folder jobs.
625
645
  */
@@ -4,7 +4,7 @@
4
4
  const DEFAULT_CODER_PACKAGE_JSON_SCRIPTS = {
5
5
  'coder:generate-boilerplates': 'ptbk coder generate-boilerplates --template ./prompts/templates/common.md',
6
6
  'coder:run':
7
- 'ptbk coder run --harness openai-codex --model gpt-5.4 --thinking-level xhigh --agent agents/developer.book --context AGENTS.md',
7
+ 'ptbk coder run --harness openai-codex --model gpt-5.5 --thinking-level xhigh --agent agents/developer.book --context AGENTS.md',
8
8
  // 'coder:find-refactor-candidates': 'ptbk coder find-refactor-candidates',
9
9
  'coder:verify': 'ptbk coder verify',
10
10
  } as const satisfies Readonly<Record<string, string>>;
@@ -1,6 +1,7 @@
1
1
  import colors from 'colors';
2
2
  import { Command as Program /* <- Note: [🔸] Using Program because Command is misleading name */ } from 'commander';
3
3
  import { spaceTrim } from 'spacetrim';
4
+ import { NotAllowed } from '../../../errors/NotAllowed';
4
5
  import { assertsError } from '../../../errors/assertsError';
5
6
  import type { $side_effect } from '../../../utils/organization/$side_effect';
6
7
  import { handleActionErrors } from '../common/handleActionErrors';
@@ -65,6 +66,11 @@ export function $initializeCoderRunCommand(program: Program): $side_effect {
65
66
  );
66
67
  addPromptRunnerExecutionOptions(command);
67
68
  command.option('--priority <minimum-priority>', 'Filter prompts by minimum priority level', parseIntOption, 0);
69
+ command.option(
70
+ '--limit <run-count>',
71
+ 'Stop after processing this many prompt runs',
72
+ parsePositiveIntegerOption,
73
+ );
68
74
  command.option(
69
75
  '--wait-after-prompt <duration>',
70
76
  spaceTrim(`
@@ -110,6 +116,7 @@ export function $initializeCoderRunCommand(program: Program): $side_effect {
110
116
  test,
111
117
  preserveLogs,
112
118
  priority,
119
+ limit,
113
120
  waitAfterPrompt: waitAfterPromptValue,
114
121
  waitBetweenPrompts: waitBetweenPromptsValue,
115
122
  waitAfterError: waitAfterErrorValue,
@@ -123,6 +130,7 @@ export function $initializeCoderRunCommand(program: Program): $side_effect {
123
130
  readonly test?: string | string[];
124
131
  readonly preserveLogs: boolean;
125
132
  readonly priority: number;
133
+ readonly limit?: number;
126
134
  readonly waitAfterPrompt?: string;
127
135
  readonly waitBetweenPrompts?: string;
128
136
  readonly waitAfterError?: string;
@@ -165,6 +173,7 @@ export function $initializeCoderRunCommand(program: Program): $side_effect {
165
173
  noUi: runnerOptions.noUi,
166
174
  thinkingLevel: runnerOptions.thinkingLevel,
167
175
  priority,
176
+ limit,
168
177
  normalizeLineEndings: runnerOptions.normalizeLineEndings,
169
178
  allowCredits: runnerOptions.allowCredits,
170
179
  autoMigrate,
@@ -204,6 +213,27 @@ function parseIntOption(value: string): number {
204
213
  return parsed;
205
214
  }
206
215
 
216
+ /**
217
+ * Parses a positive integer option value.
218
+ *
219
+ * @private internal utility of `coder run` command
220
+ */
221
+ function parsePositiveIntegerOption(value: string): number {
222
+ const parsed = Number(value);
223
+
224
+ if (!Number.isInteger(parsed) || parsed <= 0) {
225
+ throw new NotAllowed(
226
+ spaceTrim(`
227
+ Invalid value for \`--limit\`: \`${value}\`.
228
+
229
+ Use a positive integer.
230
+ `),
231
+ );
232
+ }
233
+
234
+ return parsed;
235
+ }
236
+
207
237
  /**
208
238
  * Joins one Commander option that may be parsed either as a single string or a variadic token array.
209
239
  *
@@ -1,4 +1,9 @@
1
1
  import type { string_book } from '../../book-2.0/agent-source/string_book';
2
+ import {
3
+ AGENT_VISIBILITY_VALUES,
4
+ normalizeAgentVisibility,
5
+ type AgentVisibility,
6
+ } from '../../book-2.0/agent-source/agentSourceVisibility';
2
7
  import { LimitReachedError } from '../../errors/LimitReachedError';
3
8
  import { ParseError } from '../../errors/ParseError';
4
9
  import type { LlmToolDefinition } from '../../types/LlmToolDefinition';
@@ -9,14 +14,14 @@ import { spaceTrim } from '../../utils/organization/spaceTrim';
9
14
  *
10
15
  * @private shared create-agent contract
11
16
  */
12
- export const CREATE_AGENT_VISIBILITY_VALUES = ['PRIVATE', 'UNLISTED', 'PUBLIC'] as const;
17
+ export const CREATE_AGENT_VISIBILITY_VALUES = AGENT_VISIBILITY_VALUES;
13
18
 
14
19
  /**
15
20
  * Supported visibility options for agent creation.
16
21
  *
17
22
  * @private shared create-agent contract
18
23
  */
19
- export type CreateAgentVisibility = (typeof CREATE_AGENT_VISIBILITY_VALUES)[number];
24
+ export type CreateAgentVisibility = AgentVisibility;
20
25
 
21
26
  /**
22
27
  * Canonical input payload for creating one persisted agent entity.
@@ -244,8 +249,8 @@ function parseOptionalVisibility(rawValue: unknown): CreateAgentVisibility | und
244
249
  );
245
250
  }
246
251
 
247
- const isSupportedVisibility = CREATE_AGENT_VISIBILITY_VALUES.includes(rawValue as CreateAgentVisibility);
248
- if (!isSupportedVisibility) {
252
+ const visibility = normalizeAgentVisibility(rawValue);
253
+ if (!visibility) {
249
254
  throw new ParseError(
250
255
  spaceTrim(`
251
256
  Invalid create-agent payload.
@@ -255,5 +260,5 @@ function parseOptionalVisibility(rawValue: unknown): CreateAgentVisibility | und
255
260
  );
256
261
  }
257
262
 
258
- return rawValue as CreateAgentVisibility;
263
+ return visibility;
259
264
  }
@@ -322,7 +322,7 @@ export class AgentCollectionInSupabase /* TODO: [🌈][🐱‍🚀] implements A
322
322
  ): Promise<void> {
323
323
  const selectPreviousAgentResult = await this.supabaseClient
324
324
  .from(this.getTableName('Agent'))
325
- .select('agentHash,agentName,permanentId')
325
+ .select('agentHash,agentName,permanentId,visibility')
326
326
  .eq('permanentId', permanentId)
327
327
  .single();
328
328
 
@@ -343,9 +343,12 @@ export class AgentCollectionInSupabase /* TODO: [🌈][🐱‍🚀] implements A
343
343
  const previousAgentName = selectPreviousAgentResult.data.agentName;
344
344
  const previousAgentHash = selectPreviousAgentResult.data.agentHash;
345
345
  const previousPermanentId = selectPreviousAgentResult.data.permanentId;
346
+ const previousVisibility = selectPreviousAgentResult.data.visibility;
346
347
 
347
- const preparedAgentSource = prepareAgentSourceForPersistence(agentSource);
348
- const { agentProfile, agentSource: normalizedAgentSource } = preparedAgentSource;
348
+ const preparedAgentSource = prepareAgentSourceForPersistence(agentSource, {
349
+ visibility: previousVisibility,
350
+ });
351
+ const { agentProfile, agentSource: normalizedAgentSource, visibility } = preparedAgentSource;
349
352
  let { permanentId: newPermanentId } = preparedAgentSource;
350
353
 
351
354
  const { agentHash, agentName } = agentProfile;
@@ -380,6 +383,7 @@ export class AgentCollectionInSupabase /* TODO: [🌈][🐱‍🚀] implements A
380
383
  updatedAt: new Date().toISOString(),
381
384
  agentHash: agentProfile.agentHash,
382
385
  agentSource: normalizedAgentSource,
386
+ visibility: visibility ?? previousVisibility,
383
387
  promptbookEngineVersion: PROMPTBOOK_ENGINE_VERSION,
384
388
  })
385
389
  .eq('permanentId', permanentId);
@@ -51,8 +51,11 @@ export function createAgentPersistenceRecords(
51
51
  options: CreateAgentPersistenceRecordsOptions = {},
52
52
  createdAt: string = new Date().toISOString(),
53
53
  ): CreateAgentPersistenceRecordsResult {
54
- const preparedAgentSource = prepareAgentSourceForPersistence(agentSource);
55
- const { agentProfile, agentSource: normalizedAgentSource } = preparedAgentSource;
54
+ const preparedAgentSource = prepareAgentSourceForPersistence(agentSource, {
55
+ visibility: options.visibility,
56
+ isVisibilityOverride: options.visibility !== undefined,
57
+ });
58
+ const { agentProfile, agentSource: normalizedAgentSource, visibility } = preparedAgentSource;
56
59
  const permanentId = preparedAgentSource.permanentId || $randomBase58(14);
57
60
  const { agentName, agentHash } = agentProfile;
58
61
 
@@ -74,8 +77,8 @@ export function createAgentPersistenceRecords(
74
77
  if (options.sortOrder !== undefined) {
75
78
  agentInsertRecord.sortOrder = options.sortOrder;
76
79
  }
77
- if (options.visibility !== undefined) {
78
- agentInsertRecord.visibility = options.visibility;
80
+ if (visibility !== undefined) {
81
+ agentInsertRecord.visibility = visibility;
79
82
  }
80
83
 
81
84
  return {
@@ -1,8 +1,30 @@
1
1
  import type { AgentBasicInformation } from '../../../../book-2.0/agent-source/AgentBasicInformation';
2
+ import {
3
+ DEFAULT_AGENT_VISIBILITY,
4
+ parseAgentSourceVisibility,
5
+ setAgentSourceVisibility,
6
+ type AgentVisibility,
7
+ } from '../../../../book-2.0/agent-source/agentSourceVisibility';
2
8
  import { parseAgentSource } from '../../../../book-2.0/agent-source/parseAgentSource';
3
9
  import type { string_book } from '../../../../book-2.0/agent-source/string_book';
4
10
  import type { string_agent_permanent_id } from '../../../../types/string_agent_name';
5
11
 
12
+ /**
13
+ * Options used while preparing a source for persistence.
14
+ *
15
+ * @private shared persistence helper for `AgentCollectionInSupabase`
16
+ */
17
+ export type PrepareAgentSourceForPersistenceOptions = {
18
+ /**
19
+ * Visibility value that should be written into the book when present.
20
+ */
21
+ readonly visibility?: AgentVisibility | null;
22
+ /**
23
+ * Whether `visibility` should replace an existing `META VISIBILITY` commitment.
24
+ */
25
+ readonly isVisibilityOverride?: boolean;
26
+ };
27
+
6
28
  /**
7
29
  * Prepared agent source payload ready for database persistence.
8
30
  *
@@ -24,6 +46,10 @@ export type PreparedAgentSourceForPersistence = {
24
46
  * Permanent id extracted from the original source before stripping `META ID`.
25
47
  */
26
48
  readonly permanentId: string_agent_permanent_id | undefined;
49
+ /**
50
+ * Visibility parsed from the normalized source.
51
+ */
52
+ readonly visibility: AgentVisibility | undefined;
27
53
  };
28
54
 
29
55
  /**
@@ -36,20 +62,30 @@ export type PreparedAgentSourceForPersistence = {
36
62
  *
37
63
  * @private shared persistence helper for `AgentCollectionInSupabase`
38
64
  */
39
- export function prepareAgentSourceForPersistence(agentSource: string_book): PreparedAgentSourceForPersistence {
40
- let agentProfile = parseAgentSource(agentSource);
41
- const permanentId = agentProfile.permanentId;
65
+ export function prepareAgentSourceForPersistence(
66
+ agentSource: string_book,
67
+ options: PrepareAgentSourceForPersistenceOptions = {},
68
+ ): PreparedAgentSourceForPersistence {
69
+ const originalAgentProfile = parseAgentSource(agentSource);
70
+ const permanentId = originalAgentProfile.permanentId;
42
71
 
43
- const strippedAgentSource = stripMetaIdLines(agentSource);
44
- if (strippedAgentSource !== agentSource) {
45
- agentSource = strippedAgentSource;
46
- agentProfile = parseAgentSource(agentSource);
47
- }
72
+ agentSource = stripMetaIdLines(agentSource);
73
+ const sourceVisibility = parseAgentSourceVisibility(agentSource, { isStrict: true });
74
+ const resolvedVisibility =
75
+ options.isVisibilityOverride || !sourceVisibility
76
+ ? options.visibility ?? sourceVisibility ?? DEFAULT_AGENT_VISIBILITY
77
+ : sourceVisibility;
78
+
79
+ agentSource = setAgentSourceVisibility(agentSource, resolvedVisibility);
80
+
81
+ const agentProfile = parseAgentSource(agentSource);
82
+ const visibility = parseAgentSourceVisibility(agentSource, { isStrict: true }) ?? undefined;
48
83
 
49
84
  return {
50
85
  agentProfile,
51
86
  agentSource,
52
87
  permanentId,
88
+ visibility,
53
89
  };
54
90
  }
55
91
 
@@ -0,0 +1,78 @@
1
+ import { spaceTrim } from 'spacetrim';
2
+ import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
3
+ import { TODO_USE } from '../../utils/organization/TODO_USE';
4
+ import { BaseCommitmentDefinition } from '../_base/BaseCommitmentDefinition';
5
+
6
+ /**
7
+ * META VISIBILITY commitment definition.
8
+ *
9
+ * The `META VISIBILITY` commitment stores whether an agent is public, private, or unlisted.
10
+ * Agents Server mirrors this value into the database for efficient filtering, but the book
11
+ * commitment remains the editable source of truth.
12
+ *
13
+ * @private Metadata-only commitment used by Agents Server.
14
+ */
15
+ export class MetaVisibilityCommitmentDefinition extends BaseCommitmentDefinition<'META VISIBILITY'> {
16
+ public constructor() {
17
+ super('META VISIBILITY');
18
+ }
19
+
20
+ /**
21
+ * Short one-line description of META VISIBILITY.
22
+ */
23
+ get description(): string {
24
+ return 'Set whether the agent is private, unlisted, or public.';
25
+ }
26
+
27
+ /**
28
+ * Icon for this commitment.
29
+ */
30
+ get icon(): string {
31
+ return '👁️';
32
+ }
33
+
34
+ /**
35
+ * Markdown documentation for META VISIBILITY commitment.
36
+ */
37
+ get documentation(): string {
38
+ return spaceTrim(`
39
+ # META VISIBILITY
40
+
41
+ Sets the agent visibility used by Agents Server.
42
+
43
+ ## Allowed values
44
+
45
+ - \`PRIVATE\` - accessible only to signed-in users with access.
46
+ - \`UNLISTED\` - accessible by direct link but hidden from public listings.
47
+ - \`PUBLIC\` - visible in public listings and accessible by anyone.
48
+
49
+ ## Key aspects
50
+
51
+ - Does not modify the agent's behavior, system message, or tools.
52
+ - Whitespace and letter case are normalized when persisted.
53
+ - If multiple \`META VISIBILITY\` commitments are present, persistence keeps one normalized value.
54
+ - Agents Server mirrors the value into the database for filtering, but the book is the source of truth.
55
+
56
+ ## Example
57
+
58
+ \`\`\`book
59
+ Helpful Assistant
60
+
61
+ GOAL Be helpful and friendly.
62
+ META VISIBILITY PUBLIC
63
+ \`\`\`
64
+ `);
65
+ }
66
+
67
+ public applyToAgentModelRequirements(
68
+ requirements: AgentModelRequirements,
69
+ content: string,
70
+ ): AgentModelRequirements {
71
+ TODO_USE(content);
72
+
73
+ // META VISIBILITY is metadata only and does not alter model requirements.
74
+ return requirements;
75
+ }
76
+ }
77
+
78
+ // Note: [💞] Ignore a discrepancy between file name and entity name
@@ -28,6 +28,7 @@ import { MetaFontCommitmentDefinition } from './META_FONT/META_FONT';
28
28
  import { MetaImageCommitmentDefinition } from './META_IMAGE/META_IMAGE';
29
29
  import { MetaInputPlaceholderCommitmentDefinition } from './META_INPUT_PLACEHOLDER/META_INPUT_PLACEHOLDER';
30
30
  import { MetaLinkCommitmentDefinition } from './META_LINK/META_LINK';
31
+ import { MetaVisibilityCommitmentDefinition } from './META_VISIBILITY/META_VISIBILITY';
31
32
  import { MetaVoiceCommitmentDefinition } from './META_VOICE/META_VOICE';
32
33
  import { ModelCommitmentDefinition } from './MODEL/MODEL';
33
34
  import { NoteCommitmentDefinition } from './NOTE/NOTE';
@@ -102,6 +103,7 @@ export const COMMITMENT_REGISTRY = [
102
103
  new MetaDomainCommitmentDefinition(),
103
104
  new MetaDisclaimerCommitmentDefinition(),
104
105
  new MetaInputPlaceholderCommitmentDefinition(),
106
+ new MetaVisibilityCommitmentDefinition(),
105
107
  new MetaCommitmentDefinition(),
106
108
  new MetaVoiceCommitmentDefinition(),
107
109
  new NoteCommitmentDefinition('NOTE'),