@promptbook/cli 0.112.0-41 → 0.112.0-43

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 (58) hide show
  1. package/README.md +10 -3
  2. package/esm/apps/agents-server/src/database/acquireMigrationExecutionLock.d.ts +12 -1
  3. package/esm/apps/agents-server/src/database/runDatabaseMigrations.d.ts +9 -0
  4. package/esm/index.es.js +1218 -114
  5. package/esm/index.es.js.map +1 -1
  6. package/esm/scripts/run-codex-prompts/common/formatUnknownErrorDetails.d.ts +4 -0
  7. package/esm/scripts/run-codex-prompts/common/waitForPause.d.ts +21 -1
  8. package/esm/scripts/run-codex-prompts/git/commitChanges.d.ts +2 -2
  9. package/esm/scripts/run-codex-prompts/prompts/formatPromptAttemptMetadata.d.ts +4 -0
  10. package/esm/scripts/run-codex-prompts/prompts/markPromptDone.d.ts +1 -1
  11. package/esm/scripts/run-codex-prompts/prompts/markPromptFailed.d.ts +1 -1
  12. package/esm/scripts/run-codex-prompts/testing/runPromptTestCommand.d.ts +13 -0
  13. package/esm/scripts/run-codex-prompts/testing/runPromptWithTestFeedback.d.ts +25 -0
  14. package/esm/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +112 -0
  15. package/esm/scripts/run-codex-prompts/ui/renderCoderRunUi.d.ts +30 -0
  16. package/esm/scripts/verify-prompts/verify-prompts.d.ts +23 -2
  17. package/esm/src/book-components/Chat/Chat/ChatProps.d.ts +1 -1
  18. package/esm/src/cli/cli-commands/coder/getTypescriptModule.d.ts +19 -0
  19. package/esm/src/cli/cli-commands/coder/getTypescriptModule.test.d.ts +1 -0
  20. package/esm/src/cli/cli-commands/coder/mergeStringRecordJsonFile.test.d.ts +1 -0
  21. package/esm/src/cli/cli-commands/coder/verify.test.d.ts +1 -0
  22. package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +2 -14
  23. package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/createAgentPersistenceRecords.d.ts +40 -0
  24. package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/createAgentPersistenceRecords.test.d.ts +1 -0
  25. package/esm/src/llm-providers/agent/Agent.test.d.ts +1 -0
  26. package/esm/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +4 -0
  27. package/esm/src/llm-providers/agent/AgentOptions.d.ts +8 -0
  28. package/esm/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +9 -0
  29. package/esm/src/version.d.ts +1 -1
  30. package/package.json +3 -2
  31. package/umd/apps/agents-server/src/database/acquireMigrationExecutionLock.d.ts +12 -1
  32. package/umd/apps/agents-server/src/database/runDatabaseMigrations.d.ts +9 -0
  33. package/umd/index.umd.js +1221 -118
  34. package/umd/index.umd.js.map +1 -1
  35. package/umd/scripts/run-codex-prompts/common/formatUnknownErrorDetails.d.ts +4 -0
  36. package/umd/scripts/run-codex-prompts/common/waitForPause.d.ts +21 -1
  37. package/umd/scripts/run-codex-prompts/git/commitChanges.d.ts +2 -2
  38. package/umd/scripts/run-codex-prompts/prompts/formatPromptAttemptMetadata.d.ts +4 -0
  39. package/umd/scripts/run-codex-prompts/prompts/markPromptDone.d.ts +1 -1
  40. package/umd/scripts/run-codex-prompts/prompts/markPromptFailed.d.ts +1 -1
  41. package/umd/scripts/run-codex-prompts/testing/runPromptTestCommand.d.ts +13 -0
  42. package/umd/scripts/run-codex-prompts/testing/runPromptWithTestFeedback.d.ts +25 -0
  43. package/umd/scripts/run-codex-prompts/ui/CoderRunUiState.d.ts +112 -0
  44. package/umd/scripts/run-codex-prompts/ui/renderCoderRunUi.d.ts +30 -0
  45. package/umd/scripts/verify-prompts/verify-prompts.d.ts +23 -2
  46. package/umd/src/book-components/Chat/Chat/ChatProps.d.ts +1 -1
  47. package/umd/src/cli/cli-commands/coder/getTypescriptModule.d.ts +19 -0
  48. package/umd/src/cli/cli-commands/coder/getTypescriptModule.test.d.ts +1 -0
  49. package/umd/src/cli/cli-commands/coder/mergeStringRecordJsonFile.test.d.ts +1 -0
  50. package/umd/src/cli/cli-commands/coder/verify.test.d.ts +1 -0
  51. package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +2 -14
  52. package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/createAgentPersistenceRecords.d.ts +40 -0
  53. package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/createAgentPersistenceRecords.test.d.ts +1 -0
  54. package/umd/src/llm-providers/agent/Agent.test.d.ts +1 -0
  55. package/umd/src/llm-providers/agent/AgentLlmExecutionTools.d.ts +4 -0
  56. package/umd/src/llm-providers/agent/AgentOptions.d.ts +8 -0
  57. package/umd/src/llm-providers/agent/CreateAgentLlmExecutionToolsOptions.d.ts +9 -0
  58. package/umd/src/version.d.ts +1 -1
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Formats one unknown error-like value into readable text for logs and feedback.
3
+ */
4
+ export declare function formatUnknownErrorDetails(error: unknown): string;
@@ -4,5 +4,25 @@
4
4
  export declare function listenForPause(): void;
5
5
  /**
6
6
  * If the execution is paused, it will wait until it is resumed.
7
+ *
8
+ * @param options.silent - When `true`, suppresses console output (used when the terminal UI handles display).
9
+ * @param options.onPaused - Callback invoked when entering the PAUSED state.
10
+ * @param options.onResumed - Callback invoked when leaving the PAUSED state.
7
11
  */
8
- export declare function checkPause(): Promise<void>;
12
+ export declare function checkPause(options?: {
13
+ silent?: boolean;
14
+ onPaused?: () => void;
15
+ onResumed?: () => void;
16
+ }): Promise<void>;
17
+ /**
18
+ * Returns the current pause state for external consumers such as the terminal UI.
19
+ */
20
+ export declare function getPauseState(): 'RUNNING' | 'PAUSING' | 'PAUSED';
21
+ /**
22
+ * Requests a pause from an external controller (e.g. the Ink UI).
23
+ */
24
+ export declare function requestPause(): void;
25
+ /**
26
+ * Resumes execution from an external controller after a pause.
27
+ */
28
+ export declare function requestResume(): void;
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Commits staged changes with the provided message using the dedicated coding-agent identity when configured,
3
- * otherwise falls back to the default Git configuration.
3
+ * otherwise falls back to the default Git configuration. Remote pushing is opt-in via `options.autoPush`.
4
4
  */
5
5
  export declare function commitChanges(message: string, options?: {
6
- noPush?: boolean;
6
+ autoPush?: boolean;
7
7
  }): Promise<void>;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Formats optional attempt metadata stored in prompt status lines.
3
+ */
4
+ export declare function formatPromptAttemptMetadata(status: 'done' | 'failed', attemptCount: number): string;
@@ -5,4 +5,4 @@ import type { PromptSection } from './types/PromptSection';
5
5
  /**
6
6
  * Marks a prompt section as done and records usage pricing and runner details.
7
7
  */
8
- export declare function markPromptDone(file: PromptFile, section: PromptSection, usage: Usage, runnerName: string | undefined, modelName: string | undefined, promptExecutionStartedDate: moment.Moment): void;
8
+ export declare function markPromptDone(file: PromptFile, section: PromptSection, usage: Usage, runnerName: string | undefined, modelName: string | undefined, promptExecutionStartedDate: moment.Moment, attemptCount?: number): void;
@@ -4,4 +4,4 @@ import type { PromptSection } from './types/PromptSection';
4
4
  /**
5
5
  * Marks a prompt section as failed and records runner details.
6
6
  */
7
- export declare function markPromptFailed(file: PromptFile, section: PromptSection, runnerName: string | undefined, modelName: string | undefined, promptExecutionStartedDate: moment.Moment): void;
7
+ export declare function markPromptFailed(file: PromptFile, section: PromptSection, runnerName: string | undefined, modelName: string | undefined, promptExecutionStartedDate: moment.Moment, attemptCount?: number): void;
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Options for running one verification command after a coding attempt.
3
+ */
4
+ type RunPromptTestCommandOptions = {
5
+ command: string;
6
+ projectPath: string;
7
+ scriptPath: string;
8
+ };
9
+ /**
10
+ * Runs the configured verification command inside the project root and returns its output.
11
+ */
12
+ export declare function runPromptTestCommand(options: RunPromptTestCommandOptions): Promise<string>;
13
+ export {};
@@ -0,0 +1,25 @@
1
+ import type { PromptRunOptions } from '../runners/types/PromptRunOptions';
2
+ import type { PromptRunResult } from '../runners/types/PromptRunResult';
3
+ import type { PromptRunner } from '../runners/types/PromptRunner';
4
+ import { runPromptTestCommand } from './runPromptTestCommand';
5
+ /**
6
+ * Options for running one prompt with optional verification feedback retries.
7
+ */
8
+ type RunPromptWithTestFeedbackOptions = PromptRunOptions & {
9
+ runner: PromptRunner;
10
+ promptLabel: string;
11
+ testCommand?: string;
12
+ onAttemptStarted?: (attemptCount: number) => void;
13
+ runPromptTestCommandExecutor?: typeof runPromptTestCommand;
14
+ };
15
+ /**
16
+ * Successful prompt execution result enriched with the number of attempts it took.
17
+ */
18
+ export type RunPromptWithTestFeedbackResult = PromptRunResult & {
19
+ attemptCount: number;
20
+ };
21
+ /**
22
+ * Runs one coding prompt and, when configured, verifies it with a shell command that can feed failures back.
23
+ */
24
+ export declare function runPromptWithTestFeedback(options: RunPromptWithTestFeedbackOptions): Promise<RunPromptWithTestFeedbackResult>;
25
+ export {};
@@ -0,0 +1,112 @@
1
+ /// <reference types="node" />
2
+ import { EventEmitter } from 'events';
3
+ import moment from 'moment';
4
+ import type { PromptStats } from '../prompts/types/PromptStats';
5
+ /**
6
+ * Execution phase of the coder run process.
7
+ *
8
+ * @private internal type of coder run UI
9
+ */
10
+ export type CoderRunPhase = 'initializing' | 'loading' | 'running' | 'verifying' | 'paused' | 'done' | 'error';
11
+ /**
12
+ * Configuration display data for the coder run UI header.
13
+ *
14
+ * @private internal type of coder run UI
15
+ */
16
+ export type CoderRunConfig = {
17
+ readonly agentName: string;
18
+ readonly modelName?: string;
19
+ readonly thinkingLevel?: string;
20
+ readonly context?: string;
21
+ readonly priority: number;
22
+ readonly testCommand?: string;
23
+ };
24
+ /**
25
+ * Computed progress snapshot for the coder run UI.
26
+ *
27
+ * @private internal type of coder run UI
28
+ */
29
+ export type CoderRunProgressSnapshot = {
30
+ readonly totalPrompts: number;
31
+ readonly sessionDone: number;
32
+ readonly sessionTotal: number;
33
+ readonly percentage: number;
34
+ readonly elapsedText: string;
35
+ readonly estimatedTotalText: string;
36
+ readonly estimatedLabel: string;
37
+ };
38
+ /**
39
+ * Reactive state manager for the coder run terminal UI.
40
+ *
41
+ * Holds all data the Ink components need and emits `'change'` events
42
+ * whenever any property is updated so the UI can re-render.
43
+ *
44
+ * @private internal utility of coder run UI
45
+ */
46
+ export declare class CoderRunUiState extends EventEmitter {
47
+ config: CoderRunConfig;
48
+ currentPromptLabel: string;
49
+ currentAttempt: number;
50
+ maxAttempts: number;
51
+ agentOutputLines: string[];
52
+ phase: CoderRunPhase;
53
+ statusMessage: string;
54
+ errors: string[];
55
+ private stats;
56
+ private readonly startTime;
57
+ private initialDone;
58
+ /**
59
+ * Total milliseconds the timer was paused/waiting (excluded from elapsed display).
60
+ */
61
+ private pausedMs;
62
+ /**
63
+ * Timestamp when the timer was last paused, or `undefined` when running.
64
+ */
65
+ private pausedSince;
66
+ constructor(startTime: moment.Moment);
67
+ /**
68
+ * Pauses the elapsed timer (e.g. while waiting for user input or paused state).
69
+ */
70
+ pauseTimer(): void;
71
+ /**
72
+ * Resumes the elapsed timer after a pause.
73
+ */
74
+ resumeTimer(): void;
75
+ /**
76
+ * Replaces the configuration shown in the UI header.
77
+ */
78
+ setConfig(config: CoderRunConfig): void;
79
+ /**
80
+ * Feeds new prompt statistics from the main loop so the progress bar updates.
81
+ */
82
+ updateProgress(stats: PromptStats): void;
83
+ /**
84
+ * Computes a progress snapshot on demand so elapsed time ticks with periodic re-renders.
85
+ */
86
+ getProgress(): CoderRunProgressSnapshot;
87
+ /**
88
+ * Sets the label of the prompt currently being processed and resets per-prompt state.
89
+ */
90
+ setCurrentPrompt(label: string): void;
91
+ /**
92
+ * Updates the current retry attempt number.
93
+ */
94
+ setAttempt(attempt: number): void;
95
+ /**
96
+ * Appends raw agent output text, keeping only the last `MAX_AGENT_OUTPUT_LINES`.
97
+ */
98
+ addAgentOutput(text: string): void;
99
+ /**
100
+ * Transitions the execution phase shown in the UI.
101
+ */
102
+ setPhase(phase: CoderRunPhase): void;
103
+ /**
104
+ * Updates the status message line beneath the current prompt label.
105
+ */
106
+ setStatusMessage(message: string): void;
107
+ /**
108
+ * Appends an error message to the error list shown in the UI.
109
+ */
110
+ addError(errorMessage: string): void;
111
+ private emitChange;
112
+ }
@@ -0,0 +1,30 @@
1
+ import moment from 'moment';
2
+ import { CoderRunUiState } from './CoderRunUiState';
3
+ /**
4
+ * Handle returned by `renderCoderRunUi` that exposes the state and lifecycle controls.
5
+ *
6
+ * @private internal type of coder run UI
7
+ */
8
+ export type CoderRunUiHandle = {
9
+ /** Reactive state the caller updates throughout execution. */
10
+ readonly state: CoderRunUiState;
11
+ /** Enables console interception so runner output flows into the UI agent-output area. */
12
+ startCapturingAgentOutput(): void;
13
+ /** Disables console interception so normal logging resumes. */
14
+ stopCapturingAgentOutput(): void;
15
+ /** Tears down the UI and restores original console methods. */
16
+ cleanup(): void;
17
+ };
18
+ /**
19
+ * Boots the ANSI terminal UI for `ptbk coder run`.
20
+ *
21
+ * The UI reserves a fixed number of terminal lines and repaints them periodically.
22
+ * Between repaints, any console output from runners is captured and fed into the
23
+ * scrolling agent-output area.
24
+ *
25
+ * On non-interactive (non-TTY) terminals the UI is skipped entirely and
26
+ * only the state object is provided.
27
+ *
28
+ * @private internal entry point of coder run UI
29
+ */
30
+ export declare function renderCoderRunUi(startTime: moment.Moment): CoderRunUiHandle;
@@ -1,8 +1,29 @@
1
+ import type { PromptFile } from '../run-codex-prompts/prompts/types/PromptFile';
2
+ /**
3
+ * Options supported by the prompt verification helper.
4
+ */
5
+ export type VerifyPromptsOptions = {
6
+ /**
7
+ * Process prompt files in reverse order.
8
+ */
9
+ readonly reverse?: boolean;
10
+ /**
11
+ * Ignore prompt files whose filename or first prompt line contains one of the provided values.
12
+ */
13
+ readonly ignore?: ReadonlyArray<string>;
14
+ };
1
15
  /**
2
16
  * Starts the verification loop and exits when no `[ ]` prompts remain.
3
17
  *
4
- * @param reverse - Process files in reverse order
18
+ * @public exported from `@promptbook/cli`
19
+ */
20
+ export declare function verifyPrompts(options?: VerifyPromptsOptions): Promise<void>;
21
+ /**
22
+ * Splits prompt files into files that should be verified now and files ignored for this run.
5
23
  *
6
24
  * @public exported from `@promptbook/cli`
7
25
  */
8
- export declare function verifyPrompts(reverse?: boolean): Promise<void>;
26
+ export declare function partitionPromptFilesByIgnore(promptFiles: ReadonlyArray<PromptFile>, ignoreValues: ReadonlyArray<string>): {
27
+ promptFiles: PromptFile[];
28
+ ignoredPromptFiles: PromptFile[];
29
+ };
@@ -745,7 +745,7 @@ export type ChatProps = {
745
745
  * - `BUBBLE_MODE`: keeps the default bubble appearance for all messages.
746
746
  * - `ARTICLE_MODE`: keeps user bubbles while rendering assistant replies as borderless article blocks.
747
747
  *
748
- * @default 'BUBBLE_MODE'
748
+ * @default 'ARTICLE_MODE'
749
749
  */
750
750
  readonly CHAT_VISUAL_MODE?: ChatVisualMode;
751
751
  /**
@@ -0,0 +1,19 @@
1
+ /**
2
+ * Possible runtime shapes returned when importing the `typescript` package.
3
+ */
4
+ type ImportedTypescriptModule = typeof import('typescript') | {
5
+ default: typeof import('typescript');
6
+ };
7
+ /**
8
+ * Loads the TypeScript runtime used for parsing JSONC-style project files.
9
+ *
10
+ * @private internal utility of `coder init`
11
+ */
12
+ export declare function getTypescriptModule(): Promise<typeof import('typescript')>;
13
+ /**
14
+ * Normalizes CommonJS-via-`default` and direct namespace imports of TypeScript.
15
+ *
16
+ * @private internal utility of `getTypescriptModule`
17
+ */
18
+ export declare function normalizeImportedTypescriptModule(importedTypescriptModule: ImportedTypescriptModule): typeof import('typescript');
19
+ export {};
@@ -0,0 +1 @@
1
+ export {};
@@ -4,23 +4,11 @@ import type { string_book } from '../../../../book-2.0/agent-source/string_book'
4
4
  import type { string_agent_name, string_agent_permanent_id } from '../../../../types/typeAliases';
5
5
  import { AgentCollectionInSupabaseOptions } from './AgentCollectionInSupabaseOptions';
6
6
  import type { AgentsDatabaseSchema } from './AgentsDatabaseSchema';
7
+ import { type CreateAgentPersistenceRecordsOptions } from './createAgentPersistenceRecords';
7
8
  /**
8
9
  * Options for creating a new agent entry.
9
10
  */
10
- type CreateAgentOptions = {
11
- /**
12
- * Visibility for the new agent.
13
- */
14
- readonly visibility?: 'PRIVATE' | 'UNLISTED' | 'PUBLIC';
15
- /**
16
- * Folder identifier to assign the new agent to.
17
- */
18
- readonly folderId?: number | null;
19
- /**
20
- * Sort order for the agent within its parent folder.
21
- */
22
- readonly sortOrder?: number;
23
- };
11
+ type CreateAgentOptions = CreateAgentPersistenceRecordsOptions;
24
12
  /**
25
13
  * Optional controls for persisting one source update.
26
14
  */
@@ -0,0 +1,40 @@
1
+ import type { AgentBasicInformation } from '../../../../book-2.0/agent-source/AgentBasicInformation';
2
+ import type { string_book } from '../../../../book-2.0/agent-source/string_book';
3
+ import type { CreateAgentInput } from '../../CreateAgentInput';
4
+ import type { AgentsDatabaseSchema } from './AgentsDatabaseSchema';
5
+ /**
6
+ * Optional persistence overrides for one new agent row.
7
+ *
8
+ * @private shared persistence helper for `AgentCollectionInSupabase`
9
+ */
10
+ export type CreateAgentPersistenceRecordsOptions = Omit<CreateAgentInput, 'source'>;
11
+ /**
12
+ * Prepared insert rows and returned profile for one newly persisted agent.
13
+ *
14
+ * @private shared persistence helper for `AgentCollectionInSupabase`
15
+ */
16
+ export type CreateAgentPersistenceRecordsResult = {
17
+ /**
18
+ * Parsed created agent profile including the resolved permanent id.
19
+ */
20
+ readonly createdAgent: AgentBasicInformation & Required<Pick<AgentBasicInformation, 'permanentId'>>;
21
+ /**
22
+ * Insert row for the `Agent` table.
23
+ */
24
+ readonly agentInsertRecord: AgentsDatabaseSchema['public']['Tables']['Agent']['Insert'];
25
+ /**
26
+ * Insert row for the `AgentHistory` table.
27
+ */
28
+ readonly agentHistoryInsertRecord: AgentsDatabaseSchema['public']['Tables']['AgentHistory']['Insert'];
29
+ };
30
+ /**
31
+ * Builds normalized insert rows for a newly created persisted agent.
32
+ *
33
+ * @param agentSource - Source content of the agent.
34
+ * @param options - Optional folder placement, ordering, and visibility overrides.
35
+ * @param createdAt - Shared creation timestamp used across all persisted rows.
36
+ * @returns Insert rows and the created agent profile.
37
+ *
38
+ * @private shared persistence helper for `AgentCollectionInSupabase`
39
+ */
40
+ export declare function createAgentPersistenceRecords(agentSource: string_book, options?: CreateAgentPersistenceRecordsOptions, createdAt?: string): CreateAgentPersistenceRecordsResult;
@@ -0,0 +1 @@
1
+ export {};
@@ -44,6 +44,10 @@ export declare class AgentLlmExecutionTools implements LlmExecutionTools {
44
44
  * Cached parsed agent information
45
45
  */
46
46
  private _cachedAgentInfo;
47
+ /**
48
+ * Optional server-precomputed model requirements reused until the source changes.
49
+ */
50
+ private precomputedModelRequirements;
47
51
  /**
48
52
  * Creates new AgentLlmExecutionTools
49
53
  *
@@ -1,4 +1,5 @@
1
1
  import type { string_book } from '../../book-2.0/agent-source/string_book';
2
+ import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
2
3
  import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
3
4
  import type { ExecutionTools } from '../../execution/ExecutionTools';
4
5
  import type { Updatable } from '../../types/Updatable';
@@ -27,6 +28,13 @@ export type AgentOptions = CommonToolsOptions & {
27
28
  * The source of the agent
28
29
  */
29
30
  agentSource: Updatable<string_book>;
31
+ /**
32
+ * Optional precomputed model requirements reused until `agentSource` changes.
33
+ *
34
+ * This keeps the actual runtime prompt aligned with server-prepared requirements
35
+ * such as compact-reference-resolved `TEAM` tools.
36
+ */
37
+ precomputedModelRequirements?: AgentModelRequirements;
30
38
  /**
31
39
  * Teacher agent for self-learning
32
40
  *
@@ -1,4 +1,5 @@
1
1
  import type { string_book } from '../../book-2.0/agent-source/string_book';
2
+ import type { AgentModelRequirements } from '../../book-2.0/agent-source/AgentModelRequirements';
2
3
  import type { CommonToolsOptions } from '../../execution/CommonToolsOptions';
3
4
  import type { LlmExecutionTools } from '../../execution/LlmExecutionTools';
4
5
  import type { OpenAiAgentKitExecutionTools } from '../openai/OpenAiAgentKitExecutionTools';
@@ -25,4 +26,12 @@ export type CreateAgentLlmExecutionToolsOptions = CommonToolsOptions & {
25
26
  * The agent source string that defines the agent's behavior
26
27
  */
27
28
  agentSource: string_book;
29
+ /**
30
+ * Optional precomputed model requirements reused until `agentSource` changes.
31
+ *
32
+ * This is useful for runtimes such as Agents Server that already resolved compact
33
+ * references (for example in `TEAM`) and need the executed prompt to stay aligned
34
+ * with the server-prepared tool list.
35
+ */
36
+ precomputedModelRequirements?: AgentModelRequirements;
28
37
  };
@@ -15,7 +15,7 @@ export declare const BOOK_LANGUAGE_VERSION: string_semantic_version;
15
15
  export declare const PROMPTBOOK_ENGINE_VERSION: string_promptbook_version;
16
16
  /**
17
17
  * Represents the version string of the Promptbook engine.
18
- * It follows semantic versioning (e.g., `0.112.0-40`).
18
+ * It follows semantic versioning (e.g., `0.112.0-42`).
19
19
  *
20
20
  * @generated
21
21
  */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@promptbook/cli",
3
- "version": "0.112.0-41",
3
+ "version": "0.112.0-43",
4
4
  "description": "Promptbook: Turn your company's scattered knowledge into AI ready books",
5
5
  "private": false,
6
6
  "sideEffects": false,
@@ -129,7 +129,8 @@
129
129
  "swagger-ui-express": "5.0.1",
130
130
  "type-fest": "4.5.0",
131
131
  "userhome": "1.0.1",
132
- "waitasecond": "1.11.164"
132
+ "waitasecond": "1.11.164",
133
+ "typescript": "5.2.2"
133
134
  },
134
135
  "bin": {
135
136
  "promptbook": "bin/promptbook-cli.js",
@@ -1,14 +1,25 @@
1
1
  import type { Client } from 'pg';
2
2
  import type { DatabaseMigrationLogger } from './runDatabaseMigrations';
3
+ /**
4
+ * Lock-acquisition strategies used by the migration runner.
5
+ *
6
+ * `wait` is appropriate for explicit/manual migration flows where the caller expects one serialized run.
7
+ * `skip` is appropriate for background startup checks where waiting would block request handling.
8
+ *
9
+ * @private function of runDatabaseMigrations
10
+ */
11
+ export type DatabaseMigrationExecutionLockMode = 'wait' | 'skip';
3
12
  /**
4
13
  * Acquires advisory lock preventing concurrent migration execution across processes.
5
14
  *
6
15
  * @param client Connected PostgreSQL client.
7
16
  * @param logger Logger used for progress output.
17
+ * @param mode Whether the caller should block for the lock or skip when it is already held.
18
+ * @returns `true` when the lock was acquired and migrations may proceed.
8
19
  *
9
20
  * @private function of runDatabaseMigrations
10
21
  */
11
- export declare function acquireMigrationExecutionLock(client: Client, logger: DatabaseMigrationLogger): Promise<void>;
22
+ export declare function acquireMigrationExecutionLock(client: Client, logger: DatabaseMigrationLogger, mode?: DatabaseMigrationExecutionLockMode): Promise<boolean>;
12
23
  /**
13
24
  * Releases advisory lock used for migration execution.
14
25
  *
@@ -1,4 +1,5 @@
1
1
  import { type ServerRecord } from '../utils/serverRegistry';
2
+ import { type DatabaseMigrationExecutionLockMode } from './acquireMigrationExecutionLock';
2
3
  /**
3
4
  * Allowed values describing who applied a migration record.
4
5
  */
@@ -67,6 +68,10 @@ export type RunDatabaseMigrationsOptions = {
67
68
  * If true, prints every SQL migration body before execution.
68
69
  */
69
70
  readonly logSqlStatements?: boolean;
71
+ /**
72
+ * Whether migration execution should wait for the advisory lock or skip when another process already owns it.
73
+ */
74
+ readonly executionLockMode?: DatabaseMigrationExecutionLockMode;
70
75
  };
71
76
  /**
72
77
  * Result of one prefix migration run.
@@ -97,6 +102,10 @@ export type RunDatabaseMigrationsResult = {
97
102
  * Per-prefix summary.
98
103
  */
99
104
  readonly perPrefix: ReadonlyArray<DatabaseMigrationPrefixResult>;
105
+ /**
106
+ * Whether migration execution was skipped because another process already held the advisory lock.
107
+ */
108
+ readonly isSkippedDueToActiveMigrationLock: boolean;
100
109
  };
101
110
  /**
102
111
  * Reads migration runtime configuration from environment variables and `_Server`.