@promptbook/cli 0.112.0-113 → 0.112.0-115
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]/api/user-chats/[chatId]/stream/route.ts +85 -56
- package/apps/agents-server/src/app/agents/[agentName]/chat/useAgentChatHistorySyncEffects.ts +7 -13
- package/apps/agents-server/src/database/migrations/2026-06-1300-user-chat-active-read-indexes.sql +7 -0
- package/apps/agents-server/src/utils/agentRouting/resolveAgentRouteTarget.ts +38 -0
- package/apps/agents-server/src/utils/userChat/createImmediateUserChatAnswerModelRequirements.ts +15 -12
- package/apps/agents-server/src/utils/userChat/createUserChatDetailPayload.ts +33 -18
- package/apps/agents-server/src/utils/userChat/hasPotentiallyPendingAssistantMessages.ts +26 -0
- package/apps/agents-server/src/utils/userChat/runImmediateUserChatAnswer.ts +1 -1
- package/esm/index.es.js +60 -24
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-codex-prompts/common/runGoScript/printLiveScriptChunk.d.ts +4 -0
- package/esm/src/cli/cli-commands/agent/agentCliOptions.d.ts +10 -1
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/book-3.0/LiteAgent.ts +15 -10
- package/src/cli/cli-commands/agent/agentCliOptions.ts +33 -4
- package/src/cli/cli-commands/agent/chat.ts +2 -2
- package/src/cli/cli-commands/agent/exec.ts +2 -2
- package/src/cli/cli-commands/agent.ts +0 -1
- package/src/other/templates/getTemplatesPipelineCollection.ts +773 -819
- package/src/version.ts +2 -2
- package/src/versions.txt +2 -0
- package/umd/index.umd.js +60 -24
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-codex-prompts/common/runGoScript/printLiveScriptChunk.d.ts +4 -0
- package/umd/src/cli/cli-commands/agent/agentCliOptions.d.ts +10 -1
- package/umd/src/version.d.ts +1 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { Command as Program } from 'commander';
|
|
1
2
|
import type { NormalizedPromptRunnerSelectionCliOptions, PromptRunnerSelectionCliOptions } from '../common/promptRunnerCliOptions';
|
|
2
3
|
/**
|
|
3
4
|
* Commander option bag shared by `ptbk agent` subcommands.
|
|
@@ -9,12 +10,20 @@ export type AgentCommandCliOptions = PromptRunnerSelectionCliOptions & {
|
|
|
9
10
|
readonly context?: string;
|
|
10
11
|
readonly message?: string;
|
|
11
12
|
};
|
|
13
|
+
/**
|
|
14
|
+
* Normalized shared options used by local `ptbk agent` subcommands.
|
|
15
|
+
*
|
|
16
|
+
* @private internal utility of `ptbk agent`
|
|
17
|
+
*/
|
|
18
|
+
export type NormalizedAgentCommandRunnerOptions = NormalizedPromptRunnerSelectionCliOptions & {
|
|
19
|
+
readonly isVerbose: boolean;
|
|
20
|
+
};
|
|
12
21
|
/**
|
|
13
22
|
* Normalizes shared runner flags for local agent subcommands.
|
|
14
23
|
*
|
|
15
24
|
* @private internal utility of `ptbk agent`
|
|
16
25
|
*/
|
|
17
|
-
export declare function normalizeAgentCommandRunnerOptions(cliOptions: AgentCommandCliOptions):
|
|
26
|
+
export declare function normalizeAgentCommandRunnerOptions(cliOptions: AgentCommandCliOptions, command: Program): NormalizedAgentCommandRunnerOptions;
|
|
18
27
|
/**
|
|
19
28
|
* Returns the required agent book path from Commander options.
|
|
20
29
|
*
|
package/esm/src/version.d.ts
CHANGED
|
@@ -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-
|
|
18
|
+
* It follows semantic versioning (e.g., `0.112.0-114`).
|
|
19
19
|
*
|
|
20
20
|
* @generated
|
|
21
21
|
*/
|
package/package.json
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
Agent as AgentFromKit,
|
|
3
|
+
fileSearchTool,
|
|
4
|
+
run,
|
|
5
|
+
setDefaultOpenAIClient,
|
|
6
|
+
setDefaultOpenAIKey,
|
|
7
|
+
} from '@openai/agents';
|
|
2
8
|
import { readFile } from 'fs/promises';
|
|
3
9
|
import { basename, resolve } from 'path';
|
|
4
10
|
import { fileURLToPath } from 'url';
|
|
@@ -108,11 +114,7 @@ export class LiteAgent {
|
|
|
108
114
|
|
|
109
115
|
const result = await run(
|
|
110
116
|
preparedAgent.agent,
|
|
111
|
-
createLiteAgentPromptText(
|
|
112
|
-
normalizedMessage,
|
|
113
|
-
options.context,
|
|
114
|
-
preparedAgent.modelRequirements.promptSuffix,
|
|
115
|
-
),
|
|
117
|
+
createLiteAgentPromptText(normalizedMessage, options.context, preparedAgent.modelRequirements.promptSuffix),
|
|
116
118
|
options.signal ? { signal: options.signal } : undefined,
|
|
117
119
|
);
|
|
118
120
|
|
|
@@ -187,9 +189,10 @@ export class LiteAgent {
|
|
|
187
189
|
agentKitModelName: resolvedModelName,
|
|
188
190
|
})
|
|
189
191
|
: null;
|
|
190
|
-
const agentTools =
|
|
191
|
-
|
|
192
|
-
|
|
192
|
+
const agentTools =
|
|
193
|
+
toolBuilder?.buildAgentKitTools({
|
|
194
|
+
tools: modelRequirements.tools ? [...modelRequirements.tools] : undefined,
|
|
195
|
+
}) || [];
|
|
193
196
|
const normalizedKnowledgeSources = await normalizeLiteAgentKnowledgeSources(
|
|
194
197
|
modelRequirements.knowledgeSources || [],
|
|
195
198
|
resolvedSource.sourceDirectoryPath,
|
|
@@ -427,7 +430,9 @@ async function convertLiteAgentLocalKnowledgeSourceToDataUrl(
|
|
|
427
430
|
const fileName = basename(absolutePath);
|
|
428
431
|
const mimeType = resolveLiteAgentKnowledgeSourceMimeType(fileName);
|
|
429
432
|
|
|
430
|
-
return `data:${mimeType};name=${encodeURIComponent(fileName)};base64,${fileContent.toString(
|
|
433
|
+
return `data:${mimeType};name=${encodeURIComponent(fileName)};base64,${fileContent.toString(
|
|
434
|
+
'base64',
|
|
435
|
+
)}` as string_knowledge_source_link;
|
|
431
436
|
}
|
|
432
437
|
|
|
433
438
|
/**
|
|
@@ -1,3 +1,6 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
Command as Program /* <- Note: [🔸] Using Program because Command is misleading name */,
|
|
3
|
+
} from 'commander';
|
|
1
4
|
import { NotAllowed } from '../../../errors/NotAllowed';
|
|
2
5
|
import type {
|
|
3
6
|
NormalizedPromptRunnerSelectionCliOptions,
|
|
@@ -16,6 +19,15 @@ export type AgentCommandCliOptions = PromptRunnerSelectionCliOptions & {
|
|
|
16
19
|
readonly message?: string;
|
|
17
20
|
};
|
|
18
21
|
|
|
22
|
+
/**
|
|
23
|
+
* Normalized shared options used by local `ptbk agent` subcommands.
|
|
24
|
+
*
|
|
25
|
+
* @private internal utility of `ptbk agent`
|
|
26
|
+
*/
|
|
27
|
+
export type NormalizedAgentCommandRunnerOptions = NormalizedPromptRunnerSelectionCliOptions & {
|
|
28
|
+
readonly isVerbose: boolean;
|
|
29
|
+
};
|
|
30
|
+
|
|
19
31
|
/**
|
|
20
32
|
* Normalizes shared runner flags for local agent subcommands.
|
|
21
33
|
*
|
|
@@ -23,10 +35,14 @@ export type AgentCommandCliOptions = PromptRunnerSelectionCliOptions & {
|
|
|
23
35
|
*/
|
|
24
36
|
export function normalizeAgentCommandRunnerOptions(
|
|
25
37
|
cliOptions: AgentCommandCliOptions,
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
38
|
+
command: Program,
|
|
39
|
+
): NormalizedAgentCommandRunnerOptions {
|
|
40
|
+
return {
|
|
41
|
+
...normalizePromptRunnerSelectionCliOptions(cliOptions, {
|
|
42
|
+
isAgentRequired: true,
|
|
43
|
+
}),
|
|
44
|
+
isVerbose: resolveCommandVerboseOption(command),
|
|
45
|
+
};
|
|
30
46
|
}
|
|
31
47
|
|
|
32
48
|
// Note: [🟡] Code for CLI command options [agent](src/cli/cli-commands/agent/agentCliOptions.ts) should never be published outside of `@promptbook/cli`
|
|
@@ -61,3 +77,16 @@ export function resolveRequiredAgentMessage(cliOptions: AgentCommandCliOptions):
|
|
|
61
77
|
|
|
62
78
|
return message;
|
|
63
79
|
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
* Resolves the inherited `--verbose` flag from the current Commander command chain.
|
|
83
|
+
*
|
|
84
|
+
* @private internal utility of `ptbk agent`
|
|
85
|
+
*/
|
|
86
|
+
function resolveCommandVerboseOption(command: Program): boolean {
|
|
87
|
+
const globalOptions = command.optsWithGlobals() as {
|
|
88
|
+
readonly verbose?: boolean;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
return globalOptions.verbose ?? false;
|
|
92
|
+
}
|
|
@@ -35,9 +35,9 @@ export function $initializeAgentChatCommand(program: Program): $side_effect {
|
|
|
35
35
|
command.option('--context <context-or-file>', 'Append extra context either inline or from a file path');
|
|
36
36
|
|
|
37
37
|
command.action(
|
|
38
|
-
handleActionErrors(async (cliOptions) => {
|
|
38
|
+
handleActionErrors(async (cliOptions, commandProgram) => {
|
|
39
39
|
const options = cliOptions as AgentCommandCliOptions;
|
|
40
|
-
const runnerOptions = normalizeAgentCommandRunnerOptions(options);
|
|
40
|
+
const runnerOptions = normalizeAgentCommandRunnerOptions(options, commandProgram as Program);
|
|
41
41
|
const { runAgentChat } = await import('../../../../scripts/run-agent-chat/runAgentChat');
|
|
42
42
|
|
|
43
43
|
await runAgentChat({
|
|
@@ -40,9 +40,9 @@ export function $initializeAgentExecCommand(program: Program): $side_effect {
|
|
|
40
40
|
command.option('--context <context-or-file>', 'Append extra context either inline or from a file path');
|
|
41
41
|
|
|
42
42
|
command.action(
|
|
43
|
-
handleActionErrors(async (cliOptions) => {
|
|
43
|
+
handleActionErrors(async (cliOptions, commandProgram) => {
|
|
44
44
|
const options = cliOptions as AgentCommandCliOptions;
|
|
45
|
-
const runnerOptions = normalizeAgentCommandRunnerOptions(options);
|
|
45
|
+
const runnerOptions = normalizeAgentCommandRunnerOptions(options, commandProgram as Program);
|
|
46
46
|
const { runAgentExec } = await import('../../../../scripts/run-agent-chat/runAgentExec');
|
|
47
47
|
|
|
48
48
|
await runAgentExec({
|
|
@@ -42,4 +42,3 @@ export function $initializeAgentCommand(program: Program): $side_effect {
|
|
|
42
42
|
|
|
43
43
|
// Note: [🟡] Code for CLI command [agent](src/cli/cli-commands/agent.ts) should never be published outside of `@promptbook/cli`
|
|
44
44
|
// Note: [💞] Ignore a discrepancy between file name and entity name
|
|
45
|
-
|