@promptbook/cli 0.112.0-110 → 0.112.0-111
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]/_utils.ts +7 -5
- package/apps/agents-server/src/app/agents/[agentName]/api/user-chats/[chatId]/stream/route.ts +4 -86
- package/apps/agents-server/src/components/ApplicationErrorPage/ApplicationErrorPage.tsx +118 -12
- package/apps/agents-server/src/utils/agentRouting/resolveAgentRouteTarget.ts +27 -62
- package/apps/agents-server/src/utils/errorReporting/applicationErrorHandling.ts +45 -0
- package/apps/agents-server/src/utils/errorReporting/refreshApplicationDocument.ts +10 -0
- package/apps/agents-server/src/utils/importAgent.ts +1 -57
- package/apps/agents-server/src/utils/importAgentWithFallback.ts +0 -10
- package/apps/agents-server/src/utils/userChat.ts +0 -1
- package/esm/index.es.js +18 -11
- package/esm/index.es.js.map +1 -1
- package/esm/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +22 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/cli/cli-commands/agents-server/startAgentsServer.ts +6 -1
- package/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.ts +91 -14
- package/src/other/templates/getTemplatesPipelineCollection.ts +920 -617
- package/src/version.ts +2 -2
- package/src/versions.txt +1 -0
- package/umd/index.umd.js +18 -11
- package/umd/index.umd.js.map +1 -1
- package/umd/src/collection/agent-collection/constructors/agent-collection-in-supabase/AgentCollectionInSupabase.d.ts +22 -0
- package/umd/src/version.d.ts +1 -1
- package/apps/agents-server/src/utils/userChat/getUserChatRevision.ts +0 -145
|
@@ -39,16 +39,6 @@ type ImportedAgentCacheRecord = {
|
|
|
39
39
|
*/
|
|
40
40
|
readonly source: string_book;
|
|
41
41
|
|
|
42
|
-
/**
|
|
43
|
-
* Fetch implementation that produced this cached record.
|
|
44
|
-
*/
|
|
45
|
-
readonly fetchImplementation: typeof fetch;
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Timestamp when the source was last fetched successfully.
|
|
49
|
-
*/
|
|
50
|
-
readonly cachedAt: number;
|
|
51
|
-
|
|
52
42
|
/**
|
|
53
43
|
* Last observed ETag returned by the remote `/api/book` endpoint.
|
|
54
44
|
*/
|
|
@@ -65,22 +55,6 @@ type ImportedAgentCacheRecord = {
|
|
|
65
55
|
*/
|
|
66
56
|
const IMPORTED_AGENT_CACHE = new Map<string, ImportedAgentCacheRecord>();
|
|
67
57
|
|
|
68
|
-
/**
|
|
69
|
-
* Freshness window for successful imported agent books.
|
|
70
|
-
*
|
|
71
|
-
* This avoids a remote revalidation round trip on every server render while
|
|
72
|
-
* still allowing federated/default parent updates to appear shortly after.
|
|
73
|
-
*/
|
|
74
|
-
const IMPORTED_AGENT_CACHE_FRESH_TTL_MS = 60_000;
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* Upper bound for fetching one imported agent book.
|
|
78
|
-
*
|
|
79
|
-
* Imported agents are used while rendering agent profiles and lists, so one slow
|
|
80
|
-
* federated/default parent must not block the entire Agents Server page render.
|
|
81
|
-
*/
|
|
82
|
-
const IMPORTED_AGENT_BOOK_FETCH_TIMEOUT_MS = 3_000;
|
|
83
|
-
|
|
84
58
|
/**
|
|
85
59
|
* In-flight remote imports deduplicated by canonical agent identifier.
|
|
86
60
|
*/
|
|
@@ -127,26 +101,6 @@ function createImportCacheKey(
|
|
|
127
101
|
return agentIdentification.replace(/\/+$/g, '');
|
|
128
102
|
}
|
|
129
103
|
|
|
130
|
-
/**
|
|
131
|
-
* Returns `true` when a cached imported agent can be reused without revalidation.
|
|
132
|
-
*
|
|
133
|
-
* @param cachedImport - Cached successful import record.
|
|
134
|
-
* @returns Whether the cached import is still fresh enough for immediate reuse.
|
|
135
|
-
*/
|
|
136
|
-
function isImportedAgentCacheFresh(cachedImport: ImportedAgentCacheRecord): boolean {
|
|
137
|
-
return Date.now() - cachedImport.cachedAt < IMPORTED_AGENT_CACHE_FRESH_TTL_MS;
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
/**
|
|
141
|
-
* Returns `true` when the current fetch implementation can safely reuse the cached import.
|
|
142
|
-
*
|
|
143
|
-
* @param cachedImport - Cached successful import record.
|
|
144
|
-
* @returns Whether the cache was produced by the active fetch implementation.
|
|
145
|
-
*/
|
|
146
|
-
function isImportedAgentCacheCompatible(cachedImport: ImportedAgentCacheRecord): boolean {
|
|
147
|
-
return cachedImport.fetchImplementation === globalThis.fetch;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
104
|
/**
|
|
151
105
|
* Extracts one text/book payload from a successful HTTP response.
|
|
152
106
|
*
|
|
@@ -199,14 +153,7 @@ export async function importAgent(
|
|
|
199
153
|
inheritancePath: options?.inheritancePath,
|
|
200
154
|
} satisfies ImportAgentOptions;
|
|
201
155
|
const cacheKey = createImportCacheKey(agentIdentification);
|
|
202
|
-
const
|
|
203
|
-
const cachedImport =
|
|
204
|
-
storedCachedImport && isImportedAgentCacheCompatible(storedCachedImport) ? storedCachedImport : undefined;
|
|
205
|
-
|
|
206
|
-
if (cachedImport && isImportedAgentCacheFresh(cachedImport)) {
|
|
207
|
-
return cachedImport.source;
|
|
208
|
-
}
|
|
209
|
-
|
|
156
|
+
const cachedImport = IMPORTED_AGENT_CACHE.get(cacheKey);
|
|
210
157
|
const existingRequest = PENDING_IMPORTED_AGENT_REQUESTS.get(cacheKey);
|
|
211
158
|
if (existingRequest) {
|
|
212
159
|
return existingRequest;
|
|
@@ -228,7 +175,6 @@ export async function importAgent(
|
|
|
228
175
|
const response: Response = await fetch(agentBookUrl, {
|
|
229
176
|
cache: 'no-store',
|
|
230
177
|
headers,
|
|
231
|
-
signal: AbortSignal.timeout(IMPORTED_AGENT_BOOK_FETCH_TIMEOUT_MS),
|
|
232
178
|
});
|
|
233
179
|
|
|
234
180
|
if (response.status === 304 && cachedImport) {
|
|
@@ -256,8 +202,6 @@ export async function importAgent(
|
|
|
256
202
|
const source = await readImportedAgentSource(agentIdentification, response);
|
|
257
203
|
IMPORTED_AGENT_CACHE.set(cacheKey, {
|
|
258
204
|
source,
|
|
259
|
-
fetchImplementation: globalThis.fetch,
|
|
260
|
-
cachedAt: Date.now(),
|
|
261
205
|
etag: response.headers.get('etag'),
|
|
262
206
|
lastModified: response.headers.get('last-modified'),
|
|
263
207
|
});
|
|
@@ -19,10 +19,6 @@ type FailedImportedAgentFallbackCacheRecord = {
|
|
|
19
19
|
* Generated fallback book returned for the failed import.
|
|
20
20
|
*/
|
|
21
21
|
readonly fallbackSource: string_book;
|
|
22
|
-
/**
|
|
23
|
-
* Fetch implementation that produced this failed-import fallback.
|
|
24
|
-
*/
|
|
25
|
-
readonly fetchImplementation: typeof fetch;
|
|
26
22
|
/**
|
|
27
23
|
* Cache expiration timestamp in epoch milliseconds.
|
|
28
24
|
*/
|
|
@@ -126,11 +122,6 @@ function readCachedFailedImportedAgentFallback(cacheKey: string): string_book |
|
|
|
126
122
|
return null;
|
|
127
123
|
}
|
|
128
124
|
|
|
129
|
-
if (cachedFallback.fetchImplementation !== globalThis.fetch) {
|
|
130
|
-
cachedFailedImportedAgentFallbackByKey.delete(cacheKey);
|
|
131
|
-
return null;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
125
|
return cachedFallback.fallbackSource;
|
|
135
126
|
}
|
|
136
127
|
|
|
@@ -143,7 +134,6 @@ function readCachedFailedImportedAgentFallback(cacheKey: string): string_book |
|
|
|
143
134
|
function writeCachedFailedImportedAgentFallback(cacheKey: string, fallbackSource: string_book): void {
|
|
144
135
|
cachedFailedImportedAgentFallbackByKey.set(cacheKey, {
|
|
145
136
|
fallbackSource,
|
|
146
|
-
fetchImplementation: globalThis.fetch,
|
|
147
137
|
expiresAt: Date.now() + FAILED_IMPORTED_AGENT_FALLBACK_CACHE_TTL_MS,
|
|
148
138
|
});
|
|
149
139
|
}
|
|
@@ -13,7 +13,6 @@ export { getUserChat } from './userChat/getUserChat';
|
|
|
13
13
|
export { getUserChatJob } from './userChat/getUserChatJob';
|
|
14
14
|
export { getUserChatJobById } from './userChat/getUserChatJobById';
|
|
15
15
|
export { getUserChatJobByClientMessageId } from './userChat/getUserChatJobByClientMessageId';
|
|
16
|
-
export { getUserChatRevision } from './userChat/getUserChatRevision';
|
|
17
16
|
export { heartbeatUserChatJob } from './userChat/heartbeatUserChatJob';
|
|
18
17
|
export { listExpiredRunningUserChatJobs } from './userChat/listExpiredRunningUserChatJobs';
|
|
19
18
|
export { listUserChats, listUserChatSummarySeeds } from './userChat/listUserChats';
|
package/esm/index.es.js
CHANGED
|
@@ -58,7 +58,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
58
58
|
* @generated
|
|
59
59
|
* @see https://github.com/webgptorg/promptbook
|
|
60
60
|
*/
|
|
61
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-
|
|
61
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.112.0-111';
|
|
62
62
|
/**
|
|
63
63
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
64
64
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -34200,17 +34200,19 @@ function buildCodexScript(options) {
|
|
|
34200
34200
|
var _a;
|
|
34201
34201
|
const delimiter = resolveShellHereDocumentDelimiter(CODEX_PROMPT_DELIMITER, options.prompt);
|
|
34202
34202
|
const projectPath = toPosixPath(options.projectPath);
|
|
34203
|
-
const loginMethodConfig =
|
|
34204
|
-
? 'CODEX_LOGIN_METHOD_ARGUMENTS=()'
|
|
34205
|
-
|
|
34206
|
-
|
|
34207
|
-
|
|
34208
|
-
|
|
34209
|
-
fi
|
|
34210
|
-
`);
|
|
34203
|
+
const loginMethodConfig = spaceTrim(`
|
|
34204
|
+
${options.allowCredits ? 'CODEX_LOGIN_METHOD_ARGUMENTS=()' : 'CODEX_LOGIN_METHOD_ARGUMENTS=(-c forced_login_method=chatgpt)'}
|
|
34205
|
+
if [ "\${PTBK_OPENAI_CODEX_USE_API_KEY:-0}" = "1" ] && [ -n "\${OPENAI_API_KEY:-}" ]; then
|
|
34206
|
+
CODEX_LOGIN_METHOD_ARGUMENTS=(-c forced_login_method=api)
|
|
34207
|
+
fi
|
|
34208
|
+
`);
|
|
34211
34209
|
const thinkingLevel = (_a = options.thinkingLevel) !== null && _a !== void 0 ? _a : DEFAULT_CODEX_THINKING_LEVEL;
|
|
34212
34210
|
const lines = [
|
|
34213
|
-
'if [ -f
|
|
34211
|
+
'if [ -n "${PTBK_AGENTS_SERVER_ENV_FILE:-}" ] && [ -f "${PTBK_AGENTS_SERVER_ENV_FILE}" ]; then',
|
|
34212
|
+
'set -a',
|
|
34213
|
+
'source "${PTBK_AGENTS_SERVER_ENV_FILE}"',
|
|
34214
|
+
'set +a',
|
|
34215
|
+
'elif [ -f .env ]; then',
|
|
34214
34216
|
'set -a',
|
|
34215
34217
|
'source .env',
|
|
34216
34218
|
'set +a',
|
|
@@ -37427,7 +37429,12 @@ function startNextServer(options) {
|
|
|
37427
37429
|
var _a;
|
|
37428
37430
|
const nextRuntimeModeLabel = describeAgentsServerNextRuntimeMode(options.options.nextRuntimeMode);
|
|
37429
37431
|
logRunnerEvent(options.logStreams.runner, `Starting the Agents Server Next process in ${nextRuntimeModeLabel} mode.`);
|
|
37430
|
-
const nextArguments = [
|
|
37432
|
+
const nextArguments = [
|
|
37433
|
+
options.nextCliPath,
|
|
37434
|
+
options.options.nextRuntimeMode,
|
|
37435
|
+
'--port',
|
|
37436
|
+
String(options.options.port),
|
|
37437
|
+
];
|
|
37431
37438
|
const hostname = (_a = options.childEnvironment[PTBK_HOSTNAME_ENV]) === null || _a === void 0 ? void 0 : _a.trim();
|
|
37432
37439
|
if (hostname) {
|
|
37433
37440
|
nextArguments.push('--hostname', hostname);
|