@promptbook/cli 0.112.0-117 → 0.112.0-119
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.
- package/apps/agents-server/src/app/agents/[agentName]/chat/AgentChatSidebarDefault.tsx +5 -6
- package/apps/agents-server/src/app/api/page-preview/check/route.ts +31 -0
- package/apps/agents-server/src/app/api/page-preview/screenshot/route.ts +57 -0
- package/apps/agents-server/src/app/api/upload/route.ts +10 -1
- package/apps/agents-server/src/app/s3/[first]/[second]/[hash]/[filename]/route.ts +52 -0
- package/apps/agents-server/src/database/$provideClientSql.ts +37 -0
- package/apps/agents-server/src/database/$provideSupabaseForServer.ts +41 -0
- package/apps/agents-server/src/tools/$provideCdnForServer.ts +24 -0
- package/apps/agents-server/src/utils/cdn/classes/DigitalOceanSpaces.ts +30 -2
- package/apps/agents-server/src/utils/cdn/utils/getUserFileCdnKey.ts +10 -3
- package/apps/agents-server/src/utils/externalChatRunner/processExternalUserChatJob.ts +17 -7
- package/apps/agents-server/src/utils/iframe/checkIfUrlCanBeEmbedded.ts +68 -0
- package/apps/agents-server/src/utils/localChatRunner/processLocalUserChatJob.ts +17 -7
- package/apps/agents-server/src/utils/userChat/createImmediateUserChatAnswerModelRequirements.ts +11 -0
- package/apps/agents-server/src/utils/userChat/listUserChats.ts +5 -7
- package/esm/index.es.js +442 -66
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-codex-prompts/common/parseDuration.d.ts +19 -0
- package/esm/src/_packages/node.index.d.ts +10 -0
- package/esm/src/book-3.0/BookNodeAgentSource.d.ts +1 -1
- package/esm/src/book-3.0/CliAgent.d.ts +7 -2
- package/esm/src/book-3.0/cliAgentEnv.d.ts +33 -0
- package/esm/src/book-components/BookEditor/BookEditor.d.ts +1 -1
- package/esm/src/book-components/BookEditor/BookEditorForClient.d.ts +1 -1
- package/esm/src/book-components/Chat/Chat/CitationIframePreview.d.ts +20 -0
- package/esm/src/book-components/_common/Dropdown/Dropdown.d.ts +1 -1
- package/esm/src/book-components/_common/MenuHoisting/MenuHoistingContext.d.ts +1 -1
- package/esm/src/book-components/_common/Modal/Modal.d.ts +1 -1
- package/esm/src/book-components/icons/AboutIcon.d.ts +1 -1
- package/esm/src/book-components/icons/DownloadIcon.d.ts +1 -1
- package/esm/src/book-components/icons/ExitFullscreenIcon.d.ts +1 -1
- package/esm/src/book-components/icons/FullscreenIcon.d.ts +1 -1
- package/esm/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +2 -18
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/_packages/node.index.ts +10 -0
- package/src/avatars/avatarAnimationScheduler.ts +33 -2
- package/src/avatars/visuals/fractalAvatarVisual.ts +5 -4
- package/src/avatars/visuals/minecraft2AvatarVisual.ts +16 -11
- package/src/avatars/visuals/minecraftAvatarVisual.ts +21 -7
- package/src/avatars/visuals/octopus3d2AvatarVisual.ts +69 -17
- package/src/avatars/visuals/octopus3d3AvatarVisual.ts +81 -18
- package/src/avatars/visuals/octopus3dAvatarVisual.ts +69 -17
- package/src/book-3.0/Book.ts +3 -1
- package/src/book-3.0/BookNodeAgentSource.ts +2 -2
- package/src/book-3.0/CliAgent.ts +84 -6
- package/src/book-3.0/LiteAgent.ts +1 -1
- package/src/book-3.0/cliAgentEnv.ts +46 -0
- package/src/book-components/BookEditor/BookEditor.tsx +6 -6
- package/src/book-components/BookEditor/BookEditorForClient.tsx +1 -1
- package/src/book-components/Chat/Chat/Chat.module.css +45 -0
- package/src/book-components/Chat/Chat/ChatCitationModal.tsx +2 -2
- package/src/book-components/Chat/Chat/CitationIframePreview.tsx +83 -0
- package/src/book-components/_common/Dropdown/Dropdown.tsx +1 -1
- package/src/book-components/_common/MenuHoisting/MenuHoistingContext.tsx +1 -1
- package/src/book-components/_common/Modal/Modal.tsx +1 -1
- package/src/book-components/icons/AboutIcon.tsx +1 -1
- package/src/book-components/icons/DownloadIcon.tsx +1 -1
- package/src/book-components/icons/ExitFullscreenIcon.tsx +1 -1
- package/src/book-components/icons/FullscreenIcon.tsx +1 -1
- package/src/cli/cli-commands/agents-server/buildAgentsServer.ts +31 -1
- package/src/cli/cli-commands/coder/run.ts +28 -3
- package/src/cli/cli-commands/common/promptRunnerCliOptions.ts +9 -29
- package/src/execution/createPipelineExecutor/getKnowledgeForTask.ts +1 -1
- package/src/llm-providers/openai/OpenAiAgentKitExecutionToolsToolBuilder.ts +1 -1
- package/src/llm-providers/openai/OpenAiAssistantExecutionToolsToolRunner.ts +1 -1
- package/src/llm-providers/openai/OpenAiVectorStoreKnowledgeSourcePreparer.ts +1 -1
- package/src/other/templates/getTemplatesPipelineCollection.ts +734 -711
- package/src/scripting/javascript/JavascriptEvalExecutionTools.ts +1 -1
- package/src/version.ts +2 -2
- package/src/versions.txt +2 -0
- package/umd/index.umd.js +442 -66
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-codex-prompts/common/parseDuration.d.ts +19 -0
- package/umd/src/_packages/node.index.d.ts +10 -0
- package/umd/src/book-3.0/BookNodeAgentSource.d.ts +1 -1
- package/umd/src/book-3.0/CliAgent.d.ts +7 -2
- package/umd/src/book-3.0/cliAgentEnv.d.ts +33 -0
- package/umd/src/book-components/BookEditor/BookEditor.d.ts +1 -1
- package/umd/src/book-components/BookEditor/BookEditorForClient.d.ts +1 -1
- package/umd/src/book-components/Chat/Chat/CitationIframePreview.d.ts +20 -0
- package/umd/src/book-components/_common/Dropdown/Dropdown.d.ts +1 -1
- package/umd/src/book-components/_common/MenuHoisting/MenuHoistingContext.d.ts +1 -1
- package/umd/src/book-components/_common/Modal/Modal.d.ts +1 -1
- package/umd/src/book-components/icons/AboutIcon.d.ts +1 -1
- package/umd/src/book-components/icons/DownloadIcon.d.ts +1 -1
- package/umd/src/book-components/icons/ExitFullscreenIcon.d.ts +1 -1
- package/umd/src/book-components/icons/FullscreenIcon.d.ts +1 -1
- package/umd/src/cli/cli-commands/common/promptRunnerCliOptions.d.ts +2 -18
- package/umd/src/version.d.ts +1 -1
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
|
|
3
|
+
import { useEffect, useState } from 'react';
|
|
4
|
+
import styles from './Chat.module.css';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Props for the citation iframe preview component.
|
|
8
|
+
*
|
|
9
|
+
* @private component of `<ChatCitationModal/>`
|
|
10
|
+
*/
|
|
11
|
+
export type CitationIframePreviewProps = {
|
|
12
|
+
src: string;
|
|
13
|
+
title: string;
|
|
14
|
+
};
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Internal status of the iframe embed check.
|
|
18
|
+
*
|
|
19
|
+
* @private type of `<CitationIframePreview/>`
|
|
20
|
+
*/
|
|
21
|
+
type EmbedStatus = 'loading' | 'embed' | 'screenshot';
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* Renders a citation URL preview as an iframe when the target page allows embedding,
|
|
25
|
+
* or falls back to a server-side screenshot with an "Open in new tab" link when it
|
|
26
|
+
* does not (e.g. X-Frame-Options: DENY / SAMEORIGIN).
|
|
27
|
+
*
|
|
28
|
+
* Embedding capability is determined by `GET /api/page-preview/check?url=<url>`.
|
|
29
|
+
* If that endpoint is unavailable the component falls back to the iframe directly.
|
|
30
|
+
*
|
|
31
|
+
* @private component of `<ChatCitationModal/>`
|
|
32
|
+
*/
|
|
33
|
+
export function CitationIframePreview({ src, title }: CitationIframePreviewProps) {
|
|
34
|
+
const [status, setStatus] = useState<EmbedStatus>('loading');
|
|
35
|
+
|
|
36
|
+
useEffect(() => {
|
|
37
|
+
let cancelled = false;
|
|
38
|
+
|
|
39
|
+
fetch(`/api/page-preview/check?url=${encodeURIComponent(src)}`)
|
|
40
|
+
.then((response) => response.json())
|
|
41
|
+
.then((data: { canEmbed: boolean }) => {
|
|
42
|
+
if (!cancelled) {
|
|
43
|
+
setStatus(data.canEmbed ? 'embed' : 'screenshot');
|
|
44
|
+
}
|
|
45
|
+
})
|
|
46
|
+
.catch(() => {
|
|
47
|
+
// API not available — fall back to iframe (e.g. outside agents-server)
|
|
48
|
+
if (!cancelled) {
|
|
49
|
+
setStatus('embed');
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return () => {
|
|
54
|
+
cancelled = true;
|
|
55
|
+
};
|
|
56
|
+
}, [src]);
|
|
57
|
+
|
|
58
|
+
if (status === 'loading') {
|
|
59
|
+
return <div className={styles.citationIframeLoading}>Loading preview…</div>;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
if (status === 'screenshot') {
|
|
63
|
+
return (
|
|
64
|
+
<div className={styles.citationScreenshotFallback}>
|
|
65
|
+
<img
|
|
66
|
+
src={`/api/page-preview/screenshot?url=${encodeURIComponent(src)}`}
|
|
67
|
+
alt={`Screenshot of ${title}`}
|
|
68
|
+
className={styles.citationScreenshotImage}
|
|
69
|
+
/>
|
|
70
|
+
<a
|
|
71
|
+
href={src}
|
|
72
|
+
target="_blank"
|
|
73
|
+
rel="noopener noreferrer"
|
|
74
|
+
className={styles.citationScreenshotLink}
|
|
75
|
+
>
|
|
76
|
+
Open in new tab ↗
|
|
77
|
+
</a>
|
|
78
|
+
</div>
|
|
79
|
+
);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return <iframe src={src} className={styles.citationIframe} title={title} />;
|
|
83
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use client';
|
|
2
2
|
|
|
3
|
-
import React, { ReactNode, useState } from 'react';
|
|
3
|
+
import React, { type ReactNode, useState } from 'react';
|
|
4
4
|
import { HamburgerMenu } from '../HamburgerMenu/HamburgerMenu';
|
|
5
5
|
import { classNames } from '../react-utils/classNames';
|
|
6
6
|
import styles from './Dropdown.module.css';
|
|
@@ -34,6 +34,17 @@ const AGENTS_SERVER_NEXT_BUILD_ID_FILENAME = 'BUILD_ID';
|
|
|
34
34
|
*/
|
|
35
35
|
const DEFAULT_AGENTS_SERVER_NEXT_DIST_DIRECTORY_NAME = '.next';
|
|
36
36
|
|
|
37
|
+
/**
|
|
38
|
+
* Node.js heap size limit (in MiB) injected into `NODE_OPTIONS` for the Next.js production build.
|
|
39
|
+
*
|
|
40
|
+
* Next.js webpack peaks at ~1.9 GiB on a fresh install; the Node.js default cap is ~1.7 GiB,
|
|
41
|
+
* which causes an OOM crash on first-run VPS installations where swap is the primary resource.
|
|
42
|
+
* Raising the limit lets the build complete on the first attempt.
|
|
43
|
+
*
|
|
44
|
+
* @private internal constant of `ptbk agents-server`
|
|
45
|
+
*/
|
|
46
|
+
const AGENTS_SERVER_BUILD_MAX_OLD_SPACE_MIB = 4096;
|
|
47
|
+
|
|
37
48
|
/**
|
|
38
49
|
* Environment variable passed to the bundled Next app so webpack can resolve dependencies
|
|
39
50
|
* installed beside `ptbk` even when the app sources are materialized into a project cache.
|
|
@@ -618,7 +629,13 @@ async function runNextBuild(options: {
|
|
|
618
629
|
await new Promise<void>((resolveBuild, rejectBuild) => {
|
|
619
630
|
const buildProcess = spawn(process.execPath, [options.nextCliPath, 'build'], {
|
|
620
631
|
cwd: options.appPath,
|
|
621
|
-
env:
|
|
632
|
+
env: {
|
|
633
|
+
...options.environment,
|
|
634
|
+
NODE_OPTIONS: mergeNodeOptionsWithHeapSize(
|
|
635
|
+
options.environment.NODE_OPTIONS,
|
|
636
|
+
AGENTS_SERVER_BUILD_MAX_OLD_SPACE_MIB,
|
|
637
|
+
),
|
|
638
|
+
},
|
|
622
639
|
stdio: ['ignore', 'pipe', 'pipe'],
|
|
623
640
|
});
|
|
624
641
|
|
|
@@ -641,6 +658,19 @@ async function runNextBuild(options: {
|
|
|
641
658
|
});
|
|
642
659
|
}
|
|
643
660
|
|
|
661
|
+
/**
|
|
662
|
+
* Prepends `--max-old-space-size=<mib>` to `NODE_OPTIONS` unless the caller already set one.
|
|
663
|
+
*/
|
|
664
|
+
function mergeNodeOptionsWithHeapSize(existingNodeOptions: string | undefined, maxOldSpaceMib: number): string {
|
|
665
|
+
if (existingNodeOptions !== undefined && /--max-old-space-size[= ]/u.test(existingNodeOptions)) {
|
|
666
|
+
return existingNodeOptions;
|
|
667
|
+
}
|
|
668
|
+
|
|
669
|
+
const heapFlag = `--max-old-space-size=${maxOldSpaceMib}`;
|
|
670
|
+
|
|
671
|
+
return existingNodeOptions ? `${heapFlag} ${existingNodeOptions}` : heapFlag;
|
|
672
|
+
}
|
|
673
|
+
|
|
644
674
|
/**
|
|
645
675
|
* Sends one Next build output chunk through the caller handler or to the foreground terminal.
|
|
646
676
|
*/
|
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
normalizePromptRunnerCliOptions,
|
|
12
12
|
PROMPT_RUNNER_DESCRIPTION,
|
|
13
13
|
} from '../common/promptRunnerCliOptions';
|
|
14
|
+
import { parseDuration } from '../../../../scripts/run-codex-prompts/common/parseDuration';
|
|
14
15
|
|
|
15
16
|
/**
|
|
16
17
|
* Initializes `coder run` command for Promptbook CLI utilities
|
|
@@ -57,7 +58,17 @@ export function $initializeCoderRunCommand(program: Program): $side_effect {
|
|
|
57
58
|
);
|
|
58
59
|
addPromptRunnerExecutionOptions(command);
|
|
59
60
|
command.option('--priority <minimum-priority>', 'Filter prompts by minimum priority level', parseIntOption, 0);
|
|
60
|
-
command.option(
|
|
61
|
+
command.option(
|
|
62
|
+
'--wait [duration]',
|
|
63
|
+
spaceTrim(`
|
|
64
|
+
Wait between prompt rounds.
|
|
65
|
+
Without a value (default): waits for user confirmation before each prompt (interactive mode).
|
|
66
|
+
With a duration like 1h, 30m, 5s: waits that long between prompts to avoid hitting rate limits of the harness.
|
|
67
|
+
`),
|
|
68
|
+
true,
|
|
69
|
+
);
|
|
70
|
+
// Note: --no-wait disables the default interactive wait-for-user behaviour
|
|
71
|
+
command.option('--no-wait', 'Skip all waiting between prompts and run non-interactively');
|
|
61
72
|
command.option(
|
|
62
73
|
'--auto-migrate',
|
|
63
74
|
'Run testing-server database migrations automatically after each successfully processed prompt',
|
|
@@ -76,7 +87,7 @@ export function $initializeCoderRunCommand(program: Program): $side_effect {
|
|
|
76
87
|
readonly test?: string | string[];
|
|
77
88
|
readonly preserveLogs: boolean;
|
|
78
89
|
readonly priority: number;
|
|
79
|
-
readonly wait: boolean;
|
|
90
|
+
readonly wait: boolean | string;
|
|
80
91
|
readonly autoMigrate: boolean;
|
|
81
92
|
readonly allowDestructiveAutoMigrate: boolean;
|
|
82
93
|
} & PromptRunnerCliOptions;
|
|
@@ -86,10 +97,24 @@ export function $initializeCoderRunCommand(program: Program): $side_effect {
|
|
|
86
97
|
isAgentRequired: !dryRun,
|
|
87
98
|
});
|
|
88
99
|
|
|
100
|
+
// [1] Parse the --wait option:
|
|
101
|
+
// true (default or --wait without value): wait for user confirmation
|
|
102
|
+
// false (--no-wait): no waiting at all
|
|
103
|
+
// string (--wait 1h): wait that long between prompt rounds
|
|
104
|
+
let waitForUser = false;
|
|
105
|
+
let waitBetweenPrompts = 0;
|
|
106
|
+
|
|
107
|
+
if (wait === true) {
|
|
108
|
+
waitForUser = true;
|
|
109
|
+
} else if (typeof wait === 'string' && wait !== '') {
|
|
110
|
+
waitBetweenPrompts = parseDuration(wait);
|
|
111
|
+
}
|
|
112
|
+
|
|
89
113
|
// Convert commander options to RunOptions format
|
|
90
114
|
const runOptions = {
|
|
91
115
|
dryRun,
|
|
92
|
-
waitForUser
|
|
116
|
+
waitForUser,
|
|
117
|
+
waitBetweenPrompts,
|
|
93
118
|
noCommit: runnerOptions.noCommit,
|
|
94
119
|
ignoreGitChanges: runnerOptions.ignoreGitChanges,
|
|
95
120
|
agentName: runnerOptions.agentName,
|
|
@@ -6,41 +6,21 @@ import {
|
|
|
6
6
|
import { spaceTrim } from 'spacetrim';
|
|
7
7
|
import type { ThinkingLevel } from '../coder/ThinkingLevel';
|
|
8
8
|
import { THINKING_LEVEL_VALUES } from '../coder/ThinkingLevel';
|
|
9
|
+
import {
|
|
10
|
+
CLI_AGENT_HARNESS_NAMES,
|
|
11
|
+
PTBK_HARNESS_ENV,
|
|
12
|
+
PTBK_MODEL_ENV,
|
|
13
|
+
PTBK_THINKING_LEVEL_ENV,
|
|
14
|
+
} from '../../../book-3.0/cliAgentEnv';
|
|
9
15
|
|
|
10
|
-
|
|
11
|
-
* Runner identifiers supported by Promptbook CLI agent orchestration commands.
|
|
12
|
-
*
|
|
13
|
-
* @private internal utility of `promptbookCli`
|
|
14
|
-
*/
|
|
15
|
-
export const PROMPT_RUNNER_HARNESS_NAMES = [
|
|
16
|
-
'openai-codex',
|
|
17
|
-
'github-copilot',
|
|
18
|
-
'cline',
|
|
19
|
-
'claude-code',
|
|
20
|
-
'opencode',
|
|
21
|
-
'gemini',
|
|
22
|
-
] as const;
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Environment variable used as the default runner identifier when `--harness` is omitted.
|
|
26
|
-
*
|
|
27
|
-
* @private internal utility of `promptbookCli`
|
|
28
|
-
*/
|
|
29
|
-
export const PTBK_HARNESS_ENV = 'PTBK_HARNESS';
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Environment variable used as the default runner model when `--model` is omitted.
|
|
33
|
-
*
|
|
34
|
-
* @private internal utility of `promptbookCli`
|
|
35
|
-
*/
|
|
36
|
-
export const PTBK_MODEL_ENV = 'PTBK_MODEL';
|
|
16
|
+
export { PTBK_HARNESS_ENV, PTBK_MODEL_ENV, PTBK_THINKING_LEVEL_ENV };
|
|
37
17
|
|
|
38
18
|
/**
|
|
39
|
-
*
|
|
19
|
+
* Runner identifiers supported by Promptbook CLI agent orchestration commands.
|
|
40
20
|
*
|
|
41
21
|
* @private internal utility of `promptbookCli`
|
|
42
22
|
*/
|
|
43
|
-
export const
|
|
23
|
+
export const PROMPT_RUNNER_HARNESS_NAMES = CLI_AGENT_HARNESS_NAMES;
|
|
44
24
|
|
|
45
25
|
/**
|
|
46
26
|
* Runner identifier supported by Promptbook CLI agent orchestration commands.
|
|
@@ -4,7 +4,7 @@ import { getSingleLlmExecutionTools } from '../../llm-providers/_multiple/getSin
|
|
|
4
4
|
import type { PipelineJson } from '../../pipeline/PipelineJson/PipelineJson';
|
|
5
5
|
import type { TaskJson } from '../../pipeline/PipelineJson/TaskJson';
|
|
6
6
|
import type { Parameters } from '../../types/Parameters';
|
|
7
|
-
import { Prompt } from '../../types/Prompt';
|
|
7
|
+
import type { Prompt } from '../../types/Prompt';
|
|
8
8
|
import type { string_markdown } from '../../types/string_markdown';
|
|
9
9
|
import type { string_parameter_value } from '../../types/string_name';
|
|
10
10
|
import type { ExecutionTools } from '../ExecutionTools';
|
|
@@ -449,7 +449,7 @@ export class OpenAiAgentKitExecutionToolsToolBuilder {
|
|
|
449
449
|
);
|
|
450
450
|
}
|
|
451
451
|
|
|
452
|
-
return Array.isArray(executionTools.script) ? executionTools.script : [executionTools.script];
|
|
452
|
+
return Array.isArray(executionTools.script) ? executionTools.script : [executionTools.script as ScriptExecutionTools];
|
|
453
453
|
}
|
|
454
454
|
|
|
455
455
|
/**
|
|
@@ -436,7 +436,7 @@ export class OpenAiAssistantExecutionToolsToolRunner {
|
|
|
436
436
|
|
|
437
437
|
return Array.isArray(this.options.scriptExecutionTools)
|
|
438
438
|
? this.options.scriptExecutionTools
|
|
439
|
-
: [this.options.scriptExecutionTools];
|
|
439
|
+
: [this.options.scriptExecutionTools as ScriptExecutionTools];
|
|
440
440
|
}
|
|
441
441
|
|
|
442
442
|
/**
|
|
@@ -134,7 +134,7 @@ export class OpenAiVectorStoreKnowledgeSourcePreparer {
|
|
|
134
134
|
}
|
|
135
135
|
|
|
136
136
|
return {
|
|
137
|
-
file: new File([parsed.buffer], parsed.filename, {
|
|
137
|
+
file: new File([new Uint8Array(parsed.buffer)], parsed.filename, {
|
|
138
138
|
type: parsed.mimeType,
|
|
139
139
|
}),
|
|
140
140
|
sizeBytes: parsed.buffer.length,
|