@promptbook/cli 0.113.0-5 → 0.113.0-6
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/book/route.ts +13 -1
- package/apps/agents-server/src/search/createDefaultServerSearchProviders/loadLocalOrganizationSearchDataset.ts +12 -1
- package/apps/agents-server/src/utils/agentOrganization/loadAgentOrganizationState.ts +13 -1
- package/apps/agents-server/src/utils/createLocalAgentSourceImporter.ts +159 -0
- package/apps/agents-server/src/utils/createMissingImportedAgentFallback.ts +60 -0
- package/apps/agents-server/src/utils/customDomainRouting.ts +157 -12
- package/apps/agents-server/src/utils/externalChatRunner/processExternalUserChatJob.ts +1 -1
- package/apps/agents-server/src/utils/importAgentWithFallback.ts +1 -58
- package/apps/agents-server/src/utils/localAgentRouteReferences.ts +167 -0
- package/apps/agents-server/src/utils/localChatRunner/processLocalUserChatJob.ts +1 -1
- package/apps/agents-server/src/utils/managementApi/managementApiAgents.ts +17 -3
- package/apps/agents-server/src/utils/resolveAgentStateFromSource.ts +7 -1
- package/apps/agents-server/src/utils/resolveInheritedAgentSource.ts +54 -5
- package/apps/agents-server/src/utils/resolveServerAgentContext.ts +12 -1
- package/apps/agents-server/src/utils/resolveStoredAgentState.ts +2 -1
- package/apps/agents-server/src/utils/userChat/userChatMessageLifecycle.ts +39 -9
- package/apps/agents-server/tests/e2e/support/ChatHistoryNavigationSupport.ts +5 -0
- package/esm/index.es.js +24 -36
- package/esm/index.es.js.map +1 -1
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/avatars/avatarAnimationScheduler.ts +2 -1
- package/src/avatars/visuals/octopus3d3AvatarVisual.ts +6 -2
- package/src/avatars/visuals/octopus3d4AvatarVisual.ts +14 -18
- package/src/cli/cli-commands/agents-server/buildAgentsServer.ts +3 -1
- package/src/cli/cli-commands/coder/boilerplateTemplates.ts +14 -21
- package/src/cli/cli-commands/coder/initializeCoderProjectConfiguration.ts +1 -4
- package/src/cli/cli-commands/coder/run.ts +2 -9
- package/src/commitments/TEAM/TEAM.ts +5 -5
- package/src/other/templates/getTemplatesPipelineCollection.ts +845 -662
- package/src/utils/ascii-art/convertImageDataToAsciiArt.ts +1 -4
- package/src/version.ts +2 -2
- package/src/versions.txt +1 -0
- package/umd/index.umd.js +24 -36
- package/umd/index.umd.js.map +1 -1
- package/umd/src/version.d.ts +1 -1
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
import type { string_agent_url } from '../../../../src/types/typeAliases';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Parsed local agent route reference.
|
|
5
|
+
*/
|
|
6
|
+
export type LocalAgentRouteReference = {
|
|
7
|
+
/**
|
|
8
|
+
* Matched same-instance server origin.
|
|
9
|
+
*/
|
|
10
|
+
readonly localServerUrl: string;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Decoded route identifier after `/agents/`.
|
|
14
|
+
*/
|
|
15
|
+
readonly agentIdentifier: string;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Exact local route alias for one agent URL.
|
|
20
|
+
*/
|
|
21
|
+
export type LocalAgentUrlReference = LocalAgentRouteReference & {
|
|
22
|
+
/**
|
|
23
|
+
* Normalized exact local agent URL.
|
|
24
|
+
*/
|
|
25
|
+
readonly agentUrl: string;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Normalizes same-instance server URLs for route matching.
|
|
30
|
+
*
|
|
31
|
+
* @param localServerUrls - Raw server URLs.
|
|
32
|
+
* @returns Unique normalized origins without trailing slash.
|
|
33
|
+
*/
|
|
34
|
+
export function normalizeLocalServerUrls(localServerUrls: ReadonlyArray<string>): ReadonlyArray<string> {
|
|
35
|
+
return [
|
|
36
|
+
...new Set(
|
|
37
|
+
localServerUrls
|
|
38
|
+
.map((localServerUrl) => normalizeServerUrl(localServerUrl))
|
|
39
|
+
.filter((localServerUrl) => localServerUrl.length > 0),
|
|
40
|
+
),
|
|
41
|
+
];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Normalizes exact local agent URL aliases for route matching.
|
|
46
|
+
*
|
|
47
|
+
* @param localAgentUrls - Raw local agent URLs.
|
|
48
|
+
* @returns Unique normalized route references.
|
|
49
|
+
*/
|
|
50
|
+
export function normalizeLocalAgentUrlReferences(
|
|
51
|
+
localAgentUrls: ReadonlyArray<string_agent_url>,
|
|
52
|
+
): ReadonlyArray<LocalAgentUrlReference> {
|
|
53
|
+
const localAgentUrlReferences: Array<LocalAgentUrlReference> = [];
|
|
54
|
+
const seenAgentUrls = new Set<string>();
|
|
55
|
+
|
|
56
|
+
for (const localAgentUrl of localAgentUrls) {
|
|
57
|
+
const localAgentRouteReference = parseLocalAgentRouteReference(localAgentUrl);
|
|
58
|
+
|
|
59
|
+
if (!localAgentRouteReference) {
|
|
60
|
+
continue;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const normalizedAgentUrl = createLocalAgentUrl(
|
|
64
|
+
localAgentRouteReference.localServerUrl,
|
|
65
|
+
localAgentRouteReference.agentIdentifier,
|
|
66
|
+
);
|
|
67
|
+
|
|
68
|
+
if (seenAgentUrls.has(normalizedAgentUrl)) {
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
seenAgentUrls.add(normalizedAgentUrl);
|
|
73
|
+
localAgentUrlReferences.push({
|
|
74
|
+
...localAgentRouteReference,
|
|
75
|
+
agentUrl: normalizedAgentUrl,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
return localAgentUrlReferences;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* Extracts a local agent identifier from a same-instance agent URL.
|
|
84
|
+
*
|
|
85
|
+
* @param agentUrl - Referenced agent URL.
|
|
86
|
+
* @param localServerUrls - Normalized same-instance server origins.
|
|
87
|
+
* @param localAgentUrlReferences - Exact agent URL aliases that should resolve locally.
|
|
88
|
+
* @returns Route reference or `null` when the URL belongs to another server.
|
|
89
|
+
*/
|
|
90
|
+
export function resolveLocalAgentRouteReference(
|
|
91
|
+
agentUrl: string_agent_url,
|
|
92
|
+
localServerUrls: ReadonlyArray<string>,
|
|
93
|
+
localAgentUrlReferences: ReadonlyArray<LocalAgentUrlReference>,
|
|
94
|
+
): LocalAgentRouteReference | null {
|
|
95
|
+
const localAgentRouteReference = parseLocalAgentRouteReference(agentUrl);
|
|
96
|
+
|
|
97
|
+
if (!localAgentRouteReference) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (localServerUrls.includes(localAgentRouteReference.localServerUrl)) {
|
|
102
|
+
return localAgentRouteReference;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const normalizedAgentUrl = createLocalAgentUrl(
|
|
106
|
+
localAgentRouteReference.localServerUrl,
|
|
107
|
+
localAgentRouteReference.agentIdentifier,
|
|
108
|
+
);
|
|
109
|
+
return (
|
|
110
|
+
localAgentUrlReferences.find((localAgentUrlReference) => localAgentUrlReference.agentUrl === normalizedAgentUrl) ||
|
|
111
|
+
null
|
|
112
|
+
);
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Builds one local agent profile URL.
|
|
117
|
+
*
|
|
118
|
+
* @param localServerUrl - Same-instance server origin.
|
|
119
|
+
* @param agentIdentifier - Route agent identifier.
|
|
120
|
+
* @returns Local agent URL.
|
|
121
|
+
*/
|
|
122
|
+
export function createLocalAgentUrl(localServerUrl: string, agentIdentifier: string): string_agent_url {
|
|
123
|
+
return `${localServerUrl.replace(/\/+$/g, '')}/agents/${encodeURIComponent(agentIdentifier)}` as string_agent_url;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
/**
|
|
127
|
+
* Normalizes one server URL to its origin.
|
|
128
|
+
*
|
|
129
|
+
* @param serverUrl - Raw server URL.
|
|
130
|
+
* @returns Normalized origin or an empty string when invalid.
|
|
131
|
+
*/
|
|
132
|
+
function normalizeServerUrl(serverUrl: string): string {
|
|
133
|
+
try {
|
|
134
|
+
return new URL(serverUrl).origin.replace(/\/+$/g, '');
|
|
135
|
+
} catch {
|
|
136
|
+
return serverUrl.replace(/\/+$/g, '');
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* Extracts a local route reference from an agent profile URL.
|
|
142
|
+
*
|
|
143
|
+
* @param agentUrl - Referenced agent URL.
|
|
144
|
+
* @returns Route reference or `null` when the URL is not an agent profile route.
|
|
145
|
+
*/
|
|
146
|
+
function parseLocalAgentRouteReference(agentUrl: string_agent_url): LocalAgentRouteReference | null {
|
|
147
|
+
let parsedAgentUrl: URL;
|
|
148
|
+
|
|
149
|
+
try {
|
|
150
|
+
parsedAgentUrl = new URL(agentUrl);
|
|
151
|
+
} catch {
|
|
152
|
+
return null;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
const localServerUrl = normalizeServerUrl(parsedAgentUrl.origin);
|
|
156
|
+
const pathSegments = parsedAgentUrl.pathname.split('/').filter(Boolean);
|
|
157
|
+
const agentIdentifier = pathSegments[0] === 'agents' ? pathSegments[1] : null;
|
|
158
|
+
|
|
159
|
+
if (!agentIdentifier) {
|
|
160
|
+
return null;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
return {
|
|
164
|
+
localServerUrl,
|
|
165
|
+
agentIdentifier: decodeURIComponent(agentIdentifier),
|
|
166
|
+
};
|
|
167
|
+
}
|
|
@@ -144,7 +144,7 @@ async function enqueueLocalUserChatJob(job: UserChatJobRecord): Promise<ProcessL
|
|
|
144
144
|
throw new Error(`User message "${job.userMessageId}" was not found in chat "${job.chatId}".`);
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
-
const threadMessages = createUserChatRunnerThreadMessages({
|
|
147
|
+
const threadMessages = await createUserChatRunnerThreadMessages({
|
|
148
148
|
messages: chat.messages,
|
|
149
149
|
userMessageId: job.userMessageId,
|
|
150
150
|
resolveInitialAgentMessage: () => parseAgentSource(agentSourceSnapshot.agentSource).initialMessage,
|
|
@@ -4,8 +4,10 @@ import { loadLocalOrganizationSearchDataset } from '../../search/createDefaultSe
|
|
|
4
4
|
import { stringifyJsonForSearch } from '../../search/createDefaultServerSearchProviders/stringifyJsonForSearch';
|
|
5
5
|
import { $getTableName } from '../../database/$getTableName';
|
|
6
6
|
import { $provideSupabaseForServer } from '../../database/$provideSupabaseForServer';
|
|
7
|
+
import { $provideAgentCollectionForServer } from '../../tools/$provideAgentCollectionForServer';
|
|
7
8
|
import type { OwnedAgentRow } from '../agentOwnership';
|
|
8
9
|
import { $provideAgentReferenceResolver } from '../agentReferenceResolver/$provideAgentReferenceResolver';
|
|
10
|
+
import { createLocalAgentSourceImporter } from '../createLocalAgentSourceImporter';
|
|
9
11
|
import { getWellKnownAgentUrl } from '../getWellKnownAgentUrl';
|
|
10
12
|
import { resolveCurrentOrInternalServerOrigin } from '../resolveCurrentOrInternalServerOrigin';
|
|
11
13
|
import { resolveStoredAgentState } from '../resolveStoredAgentState';
|
|
@@ -42,10 +44,22 @@ export type ManagementAgentListItem = {
|
|
|
42
44
|
* @returns Resolved agent state derived from the stored unresolved source.
|
|
43
45
|
*/
|
|
44
46
|
export async function resolveOwnedAgentDerivedState(row: OwnedAgentRow) {
|
|
47
|
+
const localServerUrl = await resolveCurrentOrInternalServerOrigin();
|
|
48
|
+
const adamAgentUrl = await getWellKnownAgentUrl('ADAM');
|
|
49
|
+
const agentReferenceResolver = await $provideAgentReferenceResolver();
|
|
50
|
+
const agentSourceImporter = createLocalAgentSourceImporter({
|
|
51
|
+
collection: await $provideAgentCollectionForServer(),
|
|
52
|
+
localServerUrls: [localServerUrl],
|
|
53
|
+
localAgentUrls: [adamAgentUrl],
|
|
54
|
+
adamAgentUrl,
|
|
55
|
+
fallbackResolver: agentReferenceResolver,
|
|
56
|
+
});
|
|
57
|
+
|
|
45
58
|
return resolveStoredAgentState(row, {
|
|
46
|
-
localServerUrl
|
|
47
|
-
adamAgentUrl
|
|
48
|
-
agentReferenceResolver
|
|
59
|
+
localServerUrl,
|
|
60
|
+
adamAgentUrl,
|
|
61
|
+
agentReferenceResolver,
|
|
62
|
+
agentSourceImporter,
|
|
49
63
|
});
|
|
50
64
|
}
|
|
51
65
|
|
|
@@ -3,7 +3,7 @@ import type { AgentReferenceResolver } from '../../../../src/book-2.0/agent-sour
|
|
|
3
3
|
import type { FederatedAgentImportConfiguration } from '../constants/federatedAgentImport';
|
|
4
4
|
import { parseAgentSource } from '../../../../src/book-2.0/agent-source/parseAgentSource';
|
|
5
5
|
import { resolveTeamCapabilitiesFromAgentSource } from './agentReferenceResolver/resolveTeamCapabilitiesFromAgentSource';
|
|
6
|
-
import { resolveInheritedAgentSource } from './resolveInheritedAgentSource';
|
|
6
|
+
import { resolveInheritedAgentSource, type AgentSourceImporter } from './resolveInheritedAgentSource';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Options for deriving the canonical resolved agent state from an editable source.
|
|
@@ -33,6 +33,11 @@ export type ResolveAgentStateFromSourceOptions = {
|
|
|
33
33
|
* Retry configuration used when loading imported agents from federated servers.
|
|
34
34
|
*/
|
|
35
35
|
readonly federatedAgentImportConfiguration?: FederatedAgentImportConfiguration;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Optional importer for same-instance agent sources.
|
|
39
|
+
*/
|
|
40
|
+
readonly agentSourceImporter?: AgentSourceImporter;
|
|
36
41
|
};
|
|
37
42
|
|
|
38
43
|
/**
|
|
@@ -112,6 +117,7 @@ export async function resolveAgentStateFromSource(
|
|
|
112
117
|
currentAgentAliases: options.currentAgentAliases,
|
|
113
118
|
agentReferenceResolver: options.agentReferenceResolver,
|
|
114
119
|
federatedAgentImportConfiguration: options.federatedAgentImportConfiguration,
|
|
120
|
+
agentSourceImporter: options.agentSourceImporter,
|
|
115
121
|
});
|
|
116
122
|
const resolvedAgentProfile = parseAgentSource(resolvedAgentSource);
|
|
117
123
|
const resolvedTeamCapabilities = await resolveTeamCapabilitiesFromAgentSource(
|
|
@@ -231,8 +231,42 @@ type ResolveInheritedAgentSourceOptions = ImportAgentOptions & {
|
|
|
231
231
|
* Retry configuration used for federated imported-agent loading.
|
|
232
232
|
*/
|
|
233
233
|
readonly federatedAgentImportConfiguration?: FederatedAgentImportConfiguration;
|
|
234
|
+
/**
|
|
235
|
+
* Optional same-instance source importer used before falling back to HTTP import.
|
|
236
|
+
*/
|
|
237
|
+
readonly agentSourceImporter?: AgentSourceImporter;
|
|
234
238
|
};
|
|
235
239
|
|
|
240
|
+
/**
|
|
241
|
+
* Context passed to a custom agent source importer.
|
|
242
|
+
*/
|
|
243
|
+
export type AgentSourceImporterContext = {
|
|
244
|
+
/**
|
|
245
|
+
* Commitment that requested the imported source.
|
|
246
|
+
*/
|
|
247
|
+
readonly commitmentType: 'FROM' | 'IMPORT';
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* Import options propagated from the current resolution pass.
|
|
251
|
+
*/
|
|
252
|
+
readonly importAgentOptions: ImportAgentOptions;
|
|
253
|
+
|
|
254
|
+
/**
|
|
255
|
+
* Retry configuration used by the default HTTP importer.
|
|
256
|
+
*/
|
|
257
|
+
readonly federatedAgentImportConfiguration: FederatedAgentImportConfiguration;
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Imports one agent source before the resolver falls back to the default HTTP importer.
|
|
262
|
+
*
|
|
263
|
+
* Return `null` when the importer does not own the given URL.
|
|
264
|
+
*/
|
|
265
|
+
export type AgentSourceImporter = (
|
|
266
|
+
agentUrl: string_agent_url,
|
|
267
|
+
context: AgentSourceImporterContext,
|
|
268
|
+
) => Promise<string_book | null>;
|
|
269
|
+
|
|
236
270
|
/**
|
|
237
271
|
* Parent inheritance state derived before rewriting the source body.
|
|
238
272
|
*/
|
|
@@ -277,6 +311,11 @@ type AgentImportContext = {
|
|
|
277
311
|
*/
|
|
278
312
|
readonly importAgentOptions: ImportAgentOptions;
|
|
279
313
|
|
|
314
|
+
/**
|
|
315
|
+
* Optional importer for same-instance agent sources.
|
|
316
|
+
*/
|
|
317
|
+
readonly agentSourceImporter?: AgentSourceImporter;
|
|
318
|
+
|
|
280
319
|
/**
|
|
281
320
|
* Original resolution options used for cycle detection.
|
|
282
321
|
*/
|
|
@@ -364,6 +403,7 @@ function createAgentImportContext(options?: ResolveInheritedAgentSourceOptions):
|
|
|
364
403
|
recursionLevel: options?.recursionLevel || 0,
|
|
365
404
|
inheritancePath: createResolutionLineage(options),
|
|
366
405
|
},
|
|
406
|
+
agentSourceImporter: options?.agentSourceImporter,
|
|
367
407
|
resolutionOptions: options,
|
|
368
408
|
};
|
|
369
409
|
}
|
|
@@ -427,11 +467,20 @@ async function importAgentCorpus(
|
|
|
427
467
|
): Promise<string> {
|
|
428
468
|
assertNoResolutionCycle(agentUrl, commitmentType, context.resolutionOptions);
|
|
429
469
|
|
|
430
|
-
const
|
|
431
|
-
agentUrl,
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
470
|
+
const locallyImportedAgentSource = context.agentSourceImporter
|
|
471
|
+
? await context.agentSourceImporter(agentUrl, {
|
|
472
|
+
commitmentType,
|
|
473
|
+
importAgentOptions: context.importAgentOptions,
|
|
474
|
+
federatedAgentImportConfiguration: context.federatedAgentImportConfiguration,
|
|
475
|
+
})
|
|
476
|
+
: null;
|
|
477
|
+
const importedAgentSource =
|
|
478
|
+
locallyImportedAgentSource ??
|
|
479
|
+
(await importAgentWithFallback(
|
|
480
|
+
agentUrl,
|
|
481
|
+
context.importAgentOptions,
|
|
482
|
+
context.federatedAgentImportConfiguration,
|
|
483
|
+
));
|
|
435
484
|
|
|
436
485
|
return getAgentSourceCorpus(importedAgentSource as string_book);
|
|
437
486
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { AgentReferenceResolver } from '../../../../src/book-2.0/agent-source/AgentReferenceResolver';
|
|
2
2
|
import type { AgentCollection } from '../../../../src/collection/agent-collection/AgentCollection';
|
|
3
3
|
import { resolveBookScopedAgentContext, type ResolvedBookScopedAgentContext } from './agentReferenceResolver/bookScopedAgentReferences';
|
|
4
|
+
import { createLocalAgentSourceImporter } from './createLocalAgentSourceImporter';
|
|
4
5
|
import { loadFederatedAgentImportConfiguration } from './federatedAgentImportConfiguration';
|
|
5
6
|
import { getWellKnownAgentUrl } from './getWellKnownAgentUrl';
|
|
6
7
|
import { resolveAgentStateFromSource, type ResolvedAgentState } from './resolveAgentStateFromSource';
|
|
@@ -46,12 +47,22 @@ export async function resolveServerAgentContext(
|
|
|
46
47
|
): Promise<ResolvedServerAgentContext> {
|
|
47
48
|
const bookScopedAgentContext = await resolveBookScopedAgentContext(options);
|
|
48
49
|
const federatedAgentImportConfiguration = await loadFederatedAgentImportConfiguration();
|
|
50
|
+
const adamAgentUrl = await getWellKnownAgentUrl('ADAM');
|
|
51
|
+
const agentSourceImporter = createLocalAgentSourceImporter({
|
|
52
|
+
collection: options.collection,
|
|
53
|
+
localServerUrls: [options.localServerUrl],
|
|
54
|
+
localAgentUrls: [adamAgentUrl],
|
|
55
|
+
adamAgentUrl,
|
|
56
|
+
fallbackResolver: options.fallbackResolver,
|
|
57
|
+
federatedAgentImportConfiguration,
|
|
58
|
+
});
|
|
49
59
|
const resolvedAgentState = await resolveAgentStateFromSource(bookScopedAgentContext.unresolvedAgentSource, {
|
|
50
|
-
adamAgentUrl
|
|
60
|
+
adamAgentUrl,
|
|
51
61
|
canonicalAgentUrl: bookScopedAgentContext.canonicalAgentUrl,
|
|
52
62
|
currentAgentAliases: bookScopedAgentContext.currentAgentAliases,
|
|
53
63
|
agentReferenceResolver: bookScopedAgentContext.scopedAgentReferenceResolver,
|
|
54
64
|
federatedAgentImportConfiguration,
|
|
65
|
+
agentSourceImporter,
|
|
55
66
|
});
|
|
56
67
|
|
|
57
68
|
return {
|
|
@@ -30,7 +30,7 @@ export type ResolvedStoredAgentState<TAgent extends StoredAgentSourceRecord> = T
|
|
|
30
30
|
*/
|
|
31
31
|
export type ResolveStoredAgentStateOptions = Pick<
|
|
32
32
|
ResolveAgentStateFromSourceOptions,
|
|
33
|
-
'adamAgentUrl' | 'agentReferenceResolver' | 'federatedAgentImportConfiguration'
|
|
33
|
+
'adamAgentUrl' | 'agentReferenceResolver' | 'federatedAgentImportConfiguration' | 'agentSourceImporter'
|
|
34
34
|
> & {
|
|
35
35
|
/**
|
|
36
36
|
* Public/current server origin used to build canonical local agent URLs.
|
|
@@ -91,6 +91,7 @@ export async function resolveStoredAgentState<TAgent extends StoredAgentSourceRe
|
|
|
91
91
|
currentAgentAliases: createCanonicalLocalAgentAliases(agent, options.localServerUrl),
|
|
92
92
|
agentReferenceResolver: options.agentReferenceResolver,
|
|
93
93
|
federatedAgentImportConfiguration,
|
|
94
|
+
agentSourceImporter: options.agentSourceImporter,
|
|
94
95
|
});
|
|
95
96
|
|
|
96
97
|
return {
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { ChatMessage } from '../../../../../src/_packages/types.index';
|
|
2
|
+
import { appendChatAttachmentContextWithContent } from '../../../../../src/utils/chat/chatAttachments/appendChatAttachmentContextWithContent';
|
|
3
|
+
|
|
2
4
|
/**
|
|
3
5
|
* Lifecycle states rendered on canonical server-owned chat messages.
|
|
4
6
|
*/
|
|
@@ -99,11 +101,11 @@ export function resolvePromptThreadBeforeUserMessage(
|
|
|
99
101
|
/**
|
|
100
102
|
* Creates the complete chat thread mirrored to a runner before it writes the next answer.
|
|
101
103
|
*/
|
|
102
|
-
export function createUserChatRunnerThreadMessages(options: {
|
|
104
|
+
export async function createUserChatRunnerThreadMessages(options: {
|
|
103
105
|
messages: ReadonlyArray<ChatMessage>;
|
|
104
106
|
userMessageId: string;
|
|
105
107
|
resolveInitialAgentMessage: () => string | null | undefined;
|
|
106
|
-
}): Array<UserChatRunnerThreadMessage
|
|
108
|
+
}): Promise<Array<UserChatRunnerThreadMessage>> {
|
|
107
109
|
const userMessage = options.messages.find((message) => message.id === options.userMessageId);
|
|
108
110
|
if (!userMessage) {
|
|
109
111
|
return [];
|
|
@@ -111,19 +113,16 @@ export function createUserChatRunnerThreadMessages(options: {
|
|
|
111
113
|
|
|
112
114
|
const previousThreadMessages = resolvePromptThreadBeforeUserMessage(options.messages, options.userMessageId);
|
|
113
115
|
|
|
114
|
-
|
|
116
|
+
const threadMessages = [
|
|
115
117
|
...createInitialUserChatRunnerThreadMessages({
|
|
116
118
|
isFirstUserTurn: previousThreadMessages.length === 0,
|
|
117
119
|
resolveInitialAgentMessage: options.resolveInitialAgentMessage,
|
|
118
120
|
}),
|
|
119
121
|
...previousThreadMessages,
|
|
120
122
|
userMessage,
|
|
121
|
-
]
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
sender: message.sender,
|
|
125
|
-
content: message.content,
|
|
126
|
-
}));
|
|
123
|
+
].filter(isUserChatRunnerThreadMessage);
|
|
124
|
+
|
|
125
|
+
return await Promise.all(threadMessages.map(createUserChatRunnerThreadMessage));
|
|
127
126
|
}
|
|
128
127
|
|
|
129
128
|
/**
|
|
@@ -176,3 +175,34 @@ function isUserChatRunnerThreadMessage(message: ChatMessage): message is ChatMes
|
|
|
176
175
|
const isRunnerSender = message.sender === 'USER' || message.sender === 'AGENT';
|
|
177
176
|
return message.isComplete !== false && isRunnerSender;
|
|
178
177
|
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Creates one runner-visible message with attachment context inlined into user-authored content.
|
|
181
|
+
*
|
|
182
|
+
* @private helper of `createUserChatRunnerThreadMessages`
|
|
183
|
+
*/
|
|
184
|
+
async function createUserChatRunnerThreadMessage(
|
|
185
|
+
message: ChatMessage & UserChatRunnerThreadMessage,
|
|
186
|
+
): Promise<UserChatRunnerThreadMessage> {
|
|
187
|
+
return {
|
|
188
|
+
sender: message.sender,
|
|
189
|
+
content: await createUserChatRunnerThreadMessageContent(message),
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/**
|
|
194
|
+
* Adds attachment URLs and best-effort text previews to user messages mirrored into runner `.book` files.
|
|
195
|
+
*
|
|
196
|
+
* @private helper of `createUserChatRunnerThreadMessage`
|
|
197
|
+
*/
|
|
198
|
+
async function createUserChatRunnerThreadMessageContent(
|
|
199
|
+
message: ChatMessage & UserChatRunnerThreadMessage,
|
|
200
|
+
): Promise<string> {
|
|
201
|
+
if (message.sender !== 'USER' || !message.attachments || message.attachments.length === 0) {
|
|
202
|
+
return message.content;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return await appendChatAttachmentContextWithContent(message.content, message.attachments, {
|
|
206
|
+
allowLocalhost: true,
|
|
207
|
+
});
|
|
208
|
+
}
|
|
@@ -212,6 +212,7 @@ async function delayNextMatchingRequest(
|
|
|
212
212
|
options: DelayNextMatchingRequestOptions,
|
|
213
213
|
): Promise<DelayedRequestControl> {
|
|
214
214
|
let hasInterceptedTargetRequest = false;
|
|
215
|
+
let isReleased = false;
|
|
215
216
|
let releaseRequest: (() => void) | null = null;
|
|
216
217
|
let markStarted: (() => void) | null = null;
|
|
217
218
|
let markFinished: (() => void) | null = null;
|
|
@@ -239,6 +240,9 @@ async function delayNextMatchingRequest(
|
|
|
239
240
|
|
|
240
241
|
await new Promise<void>((resolve) => {
|
|
241
242
|
releaseRequest = resolve;
|
|
243
|
+
if (isReleased) {
|
|
244
|
+
resolve();
|
|
245
|
+
}
|
|
242
246
|
});
|
|
243
247
|
|
|
244
248
|
try {
|
|
@@ -255,6 +259,7 @@ async function delayNextMatchingRequest(
|
|
|
255
259
|
waitUntilStarted,
|
|
256
260
|
waitUntilFinished,
|
|
257
261
|
release() {
|
|
262
|
+
isReleased = true;
|
|
258
263
|
releaseRequest?.();
|
|
259
264
|
},
|
|
260
265
|
async dispose() {
|
package/esm/index.es.js
CHANGED
|
@@ -59,7 +59,7 @@ const BOOK_LANGUAGE_VERSION = '2.0.0';
|
|
|
59
59
|
* @generated
|
|
60
60
|
* @see https://github.com/webgptorg/promptbook
|
|
61
61
|
*/
|
|
62
|
-
const PROMPTBOOK_ENGINE_VERSION = '0.113.0-
|
|
62
|
+
const PROMPTBOOK_ENGINE_VERSION = '0.113.0-6';
|
|
63
63
|
/**
|
|
64
64
|
* TODO: string_promptbook_version should be constrained to the all versions of Promptbook engine
|
|
65
65
|
* Note: [💞] Ignore a discrepancy between file name and entity name
|
|
@@ -14664,7 +14664,7 @@ const octopus3d4AvatarVisual = {
|
|
|
14664
14664
|
isAnimated: true,
|
|
14665
14665
|
supportsPointerTracking: true,
|
|
14666
14666
|
render({ context, size, palette, createRandom, timeMs, interaction }) {
|
|
14667
|
-
const { morphologyProfile, animationPhase, leftEyePhaseOffset, rightEyePhaseOffset, tentacleProfiles, skinSpots } = getOctopus3d4StableState(createRandom);
|
|
14667
|
+
const { morphologyProfile, animationPhase, leftEyePhaseOffset, rightEyePhaseOffset, tentacleProfiles, skinSpots, } = getOctopus3d4StableState(createRandom);
|
|
14668
14668
|
const sceneCenterX = size * 0.5;
|
|
14669
14669
|
const sceneCenterY = size * 0.535;
|
|
14670
14670
|
const bob = Math.sin(timeMs / 980 + animationPhase) * size * 0.013;
|
|
@@ -15012,10 +15012,7 @@ function sampleBlobbyContinuousSurfacePointWithLongitudeCache(options, latitude,
|
|
|
15012
15012
|
Math.max(0, Math.cos(effectiveLongitude)) * 0.12 +
|
|
15013
15013
|
lowerBlend * tentacleInfluence.core * (0.12 + tentacleInfluence.depthScale * 0.07) -
|
|
15014
15014
|
Math.max(0, -Math.cos(effectiveLongitude)) * 0.05;
|
|
15015
|
-
const tentacleTubeRadius = lowerBlend *
|
|
15016
|
-
tentacleInfluence.core *
|
|
15017
|
-
(0.12 + tipBlend * 0.07 + tentacleInfluence.widthScale * 0.028) *
|
|
15018
|
-
radiusX;
|
|
15015
|
+
const tentacleTubeRadius = lowerBlend * tentacleInfluence.core * (0.12 + tipBlend * 0.07 + tentacleInfluence.widthScale * 0.028) * radiusX;
|
|
15019
15016
|
const planarRadiusX = cosineLatitude * radiusX * horizontalScale + tentacleTubeRadius;
|
|
15020
15017
|
const planarRadiusZ = cosineLatitude * radiusZ * depthScale + tentacleTubeRadius * 0.74;
|
|
15021
15018
|
const lowerDrop = lowerBlend *
|
|
@@ -15027,9 +15024,7 @@ function sampleBlobbyContinuousSurfacePointWithLongitudeCache(options, latitude,
|
|
|
15027
15024
|
(morphologyProfile.tentacles.flowLengthScale - 1) * 0.1));
|
|
15028
15025
|
const combinedTentacleSway = (primaryTentacleWave + secondaryTentacleWave) * radiusX * (0.06 + tipBlend * 0.06);
|
|
15029
15026
|
return {
|
|
15030
|
-
x: Math.sin(effectiveLongitude) * planarRadiusX +
|
|
15031
|
-
combinedTentacleSway +
|
|
15032
|
-
tentacleCurl * radiusX * 0.18,
|
|
15027
|
+
x: Math.sin(effectiveLongitude) * planarRadiusX + combinedTentacleSway + tentacleCurl * radiusX * 0.18,
|
|
15033
15028
|
y: Math.sin(latitude) * radiusY * (1 + upperBlend * 0.14) -
|
|
15034
15029
|
upperBlend * radiusY * 0.12 +
|
|
15035
15030
|
lowerDrop +
|
|
@@ -18288,10 +18283,10 @@ const teamToolTitles = {};
|
|
|
18288
18283
|
*
|
|
18289
18284
|
* @private
|
|
18290
18285
|
*/
|
|
18291
|
-
const
|
|
18292
|
-
|
|
18293
|
-
|
|
18294
|
-
|
|
18286
|
+
const TEAM_SYSTEM_MESSAGE_GUIDANCE = spaceTrim$1(`
|
|
18287
|
+
- If a teammate is relevant to the request, consult that teammate using the matching tool.
|
|
18288
|
+
- Do not ask the user for information that a listed teammate can provide directly.
|
|
18289
|
+
`);
|
|
18295
18290
|
/**
|
|
18296
18291
|
* Constant for remote agents by Url.
|
|
18297
18292
|
*/
|
|
@@ -18473,7 +18468,7 @@ function buildTeamSystemMessageBody(teamEntries) {
|
|
|
18473
18468
|
`);
|
|
18474
18469
|
});
|
|
18475
18470
|
return spaceTrim$1((block) => `
|
|
18476
|
-
${block(
|
|
18471
|
+
${block(TEAM_SYSTEM_MESSAGE_GUIDANCE)}
|
|
18477
18472
|
|
|
18478
18473
|
${block(teammateSections.join('\n\n'))}
|
|
18479
18474
|
`);
|
|
@@ -40400,26 +40395,26 @@ const DEFAULT_CODER_PROMPT_TEMPLATE_DEFINITIONS = [
|
|
|
40400
40395
|
id: 'common',
|
|
40401
40396
|
relativeFilePath: join(PROMPTS_TEMPLATES_DIRECTORY_PATH, 'common.md'),
|
|
40402
40397
|
slugPrefix: null,
|
|
40403
|
-
content:
|
|
40404
|
-
|
|
40405
|
-
|
|
40406
|
-
|
|
40407
|
-
|
|
40408
|
-
|
|
40398
|
+
content: spaceTrim$1(`
|
|
40399
|
+
- @@@
|
|
40400
|
+
- Keep in mind the DRY _(don't repeat yourself)_ principle.
|
|
40401
|
+
- Do a proper analysis of the current functionality before you start implementing.
|
|
40402
|
+
- Add the changes into the [changelog](changelog/_current-preversion.md)
|
|
40403
|
+
`),
|
|
40409
40404
|
isDefaultProjectTemplate: true,
|
|
40410
40405
|
},
|
|
40411
40406
|
{
|
|
40412
40407
|
id: 'agents-server',
|
|
40413
40408
|
relativeFilePath: join(PROMPTS_TEMPLATES_DIRECTORY_PATH, 'agents-server.md'),
|
|
40414
40409
|
slugPrefix: 'agents-server',
|
|
40415
|
-
content:
|
|
40416
|
-
|
|
40417
|
-
|
|
40418
|
-
|
|
40419
|
-
|
|
40420
|
-
|
|
40421
|
-
|
|
40422
|
-
|
|
40410
|
+
content: spaceTrim$1(`
|
|
40411
|
+
- @@@
|
|
40412
|
+
- Keep in mind the DRY _(don't repeat yourself)_ principle.
|
|
40413
|
+
- Do a proper analysis of the current functionality before you start implementing.
|
|
40414
|
+
- You are working with the [Agents Server](apps/agents-server)
|
|
40415
|
+
- If you need to do the database migration, do it
|
|
40416
|
+
- Add the changes into the [changelog](changelog/_current-preversion.md)
|
|
40417
|
+
`),
|
|
40423
40418
|
isDefaultProjectTemplate: false,
|
|
40424
40419
|
},
|
|
40425
40420
|
];
|
|
@@ -40539,12 +40534,6 @@ function normalizeCoderPromptTemplateOption(templateOption) {
|
|
|
40539
40534
|
function getDefaultCoderPromptTemplateDefinitionOrUndefined(template) {
|
|
40540
40535
|
return DEFAULT_CODER_PROMPT_TEMPLATE_DEFINITIONS.find((definition) => definition.id === template);
|
|
40541
40536
|
}
|
|
40542
|
-
/**
|
|
40543
|
-
* Builds stable markdown content for one coder prompt template without indentation drift.
|
|
40544
|
-
*/
|
|
40545
|
-
function buildCoderPromptTemplateContent(lines) {
|
|
40546
|
-
return lines.join('\n');
|
|
40547
|
-
}
|
|
40548
40537
|
/**
|
|
40549
40538
|
* Creates a fully resolved template payload from one built-in definition.
|
|
40550
40539
|
*/
|
|
@@ -71938,8 +71927,7 @@ function mapColorToAnsi256(color) {
|
|
|
71938
71927
|
if (gray > ANSI_256_NEAR_WHITE_GRAY_LEVEL) {
|
|
71939
71928
|
return ANSI_256_WHITE_INDEX; // <- Note: Pure white lives in the color cube
|
|
71940
71929
|
}
|
|
71941
|
-
return
|
|
71942
|
-
Math.round(((gray - 8) / ANSI_256_GRAYSCALE_RAMP_MAX_LEVEL) * ANSI_256_GRAYSCALE_RAMP_INDEX_SPAN));
|
|
71930
|
+
return 232 + Math.round(((gray - 8) / ANSI_256_GRAYSCALE_RAMP_MAX_LEVEL) * ANSI_256_GRAYSCALE_RAMP_INDEX_SPAN);
|
|
71943
71931
|
}
|
|
71944
71932
|
const redIndex = Math.round((red / 255) * 5);
|
|
71945
71933
|
const greenIndex = Math.round((green / 255) * 5);
|