@promptbook/cli 0.114.0-10 → 0.114.0-12
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/admin/messages/MessagesClient.tsx +8 -1
- package/apps/agents-server/src/app/admin/messages/send-email/SendEmailClient.tsx +193 -63
- package/apps/agents-server/src/app/admin/messages/send-email/actions.ts +25 -28
- package/apps/agents-server/src/app/admin/messages/send-email/emailTesting.ts +153 -0
- package/apps/agents-server/src/app/admin/messages/send-email/emailTestingAccess.ts +30 -0
- package/apps/agents-server/src/app/admin/messages/send-email/page.tsx +18 -5
- package/apps/agents-server/src/app/api/internal/agent-goal-chat-planned-messages/route.ts +34 -7
- package/apps/agents-server/src/message-providers/email/stalwart/StalwartMessageProvider.ts +2 -1
- package/apps/agents-server/src/utils/email/agentEmailAddress.ts +14 -0
- package/apps/agents-server/src/utils/email/sendEmailThroughStalwart.ts +2 -1
- package/esm/index.es.js +404 -115
- package/esm/index.es.js.map +1 -1
- package/esm/scripts/run-codex-prompts/common/runGoScript/$spawnLoggedBashScript.d.ts +25 -0
- package/esm/scripts/run-codex-prompts/common/runGoScript/$terminateLoggedBashProcessTree.d.ts +11 -0
- package/esm/scripts/run-codex-prompts/common/runGoScript/scriptExecutionLog.d.ts +4 -0
- package/esm/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +5 -0
- package/esm/src/book-2.0/agent-source/ParsedUnknownCommitment.d.ts +26 -0
- package/esm/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.unknown.test.d.ts +1 -0
- package/esm/src/book-2.0/agent-source/getBookCommitmentLineType.d.ts +19 -0
- package/esm/src/book-2.0/agent-source/parseAgentSourceWithCommitments.unknown.test.d.ts +1 -0
- package/esm/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.d.ts +28 -0
- package/esm/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/harness/$checkHarnessInstallation.d.ts +3 -3
- package/esm/src/cli/cli-commands/common/harness/$checkHarnessInstallation.test.d.ts +1 -0
- package/esm/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +3 -3
- package/esm/src/cli/cli-commands/common/harness/HarnessInstallationStatus.d.ts +3 -2
- package/esm/src/cli/cli-commands/common/harnessUpdateCliOptions.d.ts +29 -0
- package/esm/src/cli/cli-commands/common/harnessUpdateCliOptions.test.d.ts +1 -0
- package/esm/src/executables/platforms/locateAppOnWindows.d.ts +1 -1
- package/esm/src/executables/platforms/locateAppOnWindows.test.d.ts +1 -0
- package/esm/src/version.d.ts +1 -1
- package/package.json +1 -1
- package/src/book-2.0/agent-source/AgentSourceParseResult.ts +6 -0
- package/src/book-2.0/agent-source/ParsedUnknownCommitment.ts +29 -0
- package/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments/augmentAgentModelRequirementsFromSource.ts +38 -1
- package/src/book-2.0/agent-source/getBookCommitmentLineType.ts +36 -0
- package/src/book-2.0/agent-source/parseAgentSourceWithCommitments.ts +128 -61
- package/src/book-components/BookEditor/BookEditorMonaco.tsx +6 -1
- package/src/book-components/BookEditor/BookEditorMonacoTokenization.ts +3 -1
- package/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.ts +50 -0
- package/src/cli/cli-commands/coder/boilerplateTemplates.ts +3 -15
- package/src/cli/cli-commands/coder/init.ts +11 -2
- package/src/cli/cli-commands/coder/ping.ts +11 -1
- package/src/cli/cli-commands/coder/run.ts +11 -2
- package/src/cli/cli-commands/coder/server.ts +11 -2
- package/src/cli/cli-commands/common/harness/$applyHarnessInstallationStatus.ts +5 -0
- package/src/cli/cli-commands/common/harness/$checkHarnessInstallation.ts +17 -5
- package/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.ts +6 -3
- package/src/cli/cli-commands/common/harness/HarnessInstallationStatus.ts +3 -2
- package/src/cli/cli-commands/common/harnessUpdateCliOptions.ts +49 -0
- package/src/executables/platforms/locateAppOnWindows.ts +12 -9
- package/src/other/templates/getTemplatesPipelineCollection.ts +881 -685
- package/src/version.ts +2 -2
- package/src/versions.txt +1 -0
- package/umd/index.umd.js +403 -114
- package/umd/index.umd.js.map +1 -1
- package/umd/scripts/run-codex-prompts/common/runGoScript/$spawnLoggedBashScript.d.ts +25 -0
- package/umd/scripts/run-codex-prompts/common/runGoScript/$terminateLoggedBashProcessTree.d.ts +11 -0
- package/umd/scripts/run-codex-prompts/common/runGoScript/scriptExecutionLog.d.ts +4 -0
- package/umd/src/book-2.0/agent-source/AgentSourceParseResult.d.ts +5 -0
- package/umd/src/book-2.0/agent-source/ParsedUnknownCommitment.d.ts +26 -0
- package/umd/src/book-2.0/agent-source/createAgentModelRequirementsWithCommitments.unknown.test.d.ts +1 -0
- package/umd/src/book-2.0/agent-source/getBookCommitmentLineType.d.ts +19 -0
- package/umd/src/book-2.0/agent-source/parseAgentSourceWithCommitments.unknown.test.d.ts +1 -0
- package/umd/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.d.ts +28 -0
- package/umd/src/book-components/BookEditor/createUnknownCommitmentDiagnostics.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/harness/$checkHarnessInstallation.d.ts +3 -3
- package/umd/src/cli/cli-commands/common/harness/$checkHarnessInstallation.test.d.ts +1 -0
- package/umd/src/cli/cli-commands/common/harness/$ensureHarnessInstallations.d.ts +3 -3
- package/umd/src/cli/cli-commands/common/harness/HarnessInstallationStatus.d.ts +3 -2
- package/umd/src/cli/cli-commands/common/harnessUpdateCliOptions.d.ts +29 -0
- package/umd/src/cli/cli-commands/common/harnessUpdateCliOptions.test.d.ts +1 -0
- package/umd/src/executables/platforms/locateAppOnWindows.d.ts +1 -1
- package/umd/src/executables/platforms/locateAppOnWindows.test.d.ts +1 -0
- package/umd/src/version.d.ts +1 -1
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server';
|
|
2
2
|
import { spaceTrim } from 'spacetrim';
|
|
3
3
|
import { LimitReachedError } from '../../../../../../../src/errors/LimitReachedError';
|
|
4
|
+
import { NotFoundError } from '../../../../../../../src/errors/NotFoundError';
|
|
4
5
|
import { ParseError } from '../../../../../../../src/errors/ParseError';
|
|
5
6
|
import { isTimingSafeEqualString } from '../../../../../../../src/utils/isTimingSafeEqualString';
|
|
6
7
|
import { USER_CHAT_WORKER_TOKEN_HEADER } from '@/src/utils/agentProjects/agentProjectRuntimeConstants';
|
|
7
8
|
import { AGENT_GOAL_CHAT_PLANNED_MESSAGE_ACTIONS } from '@/src/utils/agentGoalChat/agentGoalChatPlannedMessageActions';
|
|
9
|
+
import { $provideAgentCollectionForServer } from '@/src/tools/$provideAgentCollectionForServer';
|
|
8
10
|
import { resolveUserChatWorkerInternalToken } from '@/src/utils/userChat';
|
|
9
11
|
|
|
10
12
|
/**
|
|
@@ -52,6 +54,10 @@ export async function POST(request: Request) {
|
|
|
52
54
|
return NextResponse.json({ error: error.message }, { status: 429 });
|
|
53
55
|
}
|
|
54
56
|
|
|
57
|
+
if (error instanceof NotFoundError) {
|
|
58
|
+
return NextResponse.json({ error: error.message }, { status: 404 });
|
|
59
|
+
}
|
|
60
|
+
|
|
55
61
|
console.error('[agent-goal-chat-planned-messages] internal route failed', error);
|
|
56
62
|
return NextResponse.json(
|
|
57
63
|
{
|
|
@@ -82,11 +88,11 @@ async function parseAgentGoalChatPlannedMessageRequest(request: Request): Promis
|
|
|
82
88
|
* Executes one normalized planned-message request through the shared action service.
|
|
83
89
|
*/
|
|
84
90
|
async function executeAgentGoalChatPlannedMessageRequest(request: AgentGoalChatPlannedMessageRequest) {
|
|
85
|
-
const agentPermanentId = request.body.agentPermanentId;
|
|
91
|
+
const agentPermanentId = await resolveCanonicalAgentPermanentId(request.body.agentPermanentId);
|
|
86
92
|
|
|
87
93
|
if (request.action === 'set') {
|
|
88
94
|
return await AGENT_GOAL_CHAT_PLANNED_MESSAGE_ACTIONS.set({
|
|
89
|
-
agentPermanentId
|
|
95
|
+
agentPermanentId,
|
|
90
96
|
milliseconds: request.body.milliseconds,
|
|
91
97
|
message: request.body.message,
|
|
92
98
|
});
|
|
@@ -94,14 +100,14 @@ async function executeAgentGoalChatPlannedMessageRequest(request: AgentGoalChatP
|
|
|
94
100
|
|
|
95
101
|
if (request.action === 'list') {
|
|
96
102
|
return await AGENT_GOAL_CHAT_PLANNED_MESSAGE_ACTIONS.list({
|
|
97
|
-
agentPermanentId
|
|
103
|
+
agentPermanentId,
|
|
98
104
|
isIncludingFinished: request.body.isIncludingFinished,
|
|
99
105
|
limit: request.body.limit,
|
|
100
106
|
});
|
|
101
107
|
}
|
|
102
108
|
|
|
103
109
|
return await AGENT_GOAL_CHAT_PLANNED_MESSAGE_ACTIONS.cancel({
|
|
104
|
-
agentPermanentId
|
|
110
|
+
agentPermanentId,
|
|
105
111
|
timeoutId: request.body.timeoutId,
|
|
106
112
|
});
|
|
107
113
|
}
|
|
@@ -127,14 +133,35 @@ function normalizeAgentGoalChatPlannedMessageAction(rawAction: unknown): AgentGo
|
|
|
127
133
|
}
|
|
128
134
|
|
|
129
135
|
/**
|
|
130
|
-
*
|
|
136
|
+
* Resolves an agent identifier to its canonical permanent id before persistence.
|
|
137
|
+
*
|
|
138
|
+
* Coding runners identify local folders with lowercase ids, while goal-chat and
|
|
139
|
+
* timeout records use the canonical database id.
|
|
140
|
+
*
|
|
141
|
+
* @param rawAgentPermanentId - Untrusted identifier from the internal runtime request.
|
|
142
|
+
* @returns The canonical permanent id of the active agent.
|
|
131
143
|
*/
|
|
132
|
-
function
|
|
144
|
+
async function resolveCanonicalAgentPermanentId(rawAgentPermanentId: unknown): Promise<string> {
|
|
133
145
|
if (typeof rawAgentPermanentId !== 'string' || rawAgentPermanentId.trim().length === 0) {
|
|
134
146
|
throw new ParseError('Missing required `agentPermanentId` string.');
|
|
135
147
|
}
|
|
136
148
|
|
|
137
|
-
|
|
149
|
+
const requestedAgentIdentifier = rawAgentPermanentId.trim();
|
|
150
|
+
const collection = await $provideAgentCollectionForServer();
|
|
151
|
+
const agent = await collection.findAgentBasicInformation(requestedAgentIdentifier);
|
|
152
|
+
const agentPermanentId = agent?.permanentId?.trim();
|
|
153
|
+
|
|
154
|
+
if (!agentPermanentId) {
|
|
155
|
+
throw new NotFoundError(
|
|
156
|
+
spaceTrim(`
|
|
157
|
+
Agent \`${requestedAgentIdentifier}\` was not found.
|
|
158
|
+
|
|
159
|
+
**Note:** Planned messages can only be managed for an active Agents Server agent.
|
|
160
|
+
`),
|
|
161
|
+
);
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
return agentPermanentId;
|
|
138
165
|
}
|
|
139
166
|
|
|
140
167
|
/**
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { really_any } from '@promptbook-local/types';
|
|
2
|
+
import { getEmailAddressDomain } from '../../../utils/email/agentEmailAddress';
|
|
2
3
|
import { buildStalwartMailBridgeAddress } from '../../../utils/stalwart/stalwartMailBridge';
|
|
3
4
|
import type { MessageProvider } from '../../interfaces/MessageProvider';
|
|
4
5
|
import type { OutboundEmail } from '../_common/Email';
|
|
@@ -51,7 +52,7 @@ export class StalwartMessageProvider implements MessageProvider {
|
|
|
51
52
|
*/
|
|
52
53
|
public async send(message: OutboundEmail): Promise<really_any> {
|
|
53
54
|
const senderAddress = parseEmailAddress(message.sender).fullEmail;
|
|
54
|
-
const senderDomain =
|
|
55
|
+
const senderDomain = getEmailAddressDomain(senderAddress);
|
|
55
56
|
const provider = new SmtpMessageProvider({
|
|
56
57
|
host: this.configuration.host,
|
|
57
58
|
port: this.configuration.port,
|
|
@@ -82,6 +82,20 @@ export function extractEmailAddress(value: string): string {
|
|
|
82
82
|
return value.match(/<\s*([^>]+?)\s*>/)?.[1]?.trim() || value.trim();
|
|
83
83
|
}
|
|
84
84
|
|
|
85
|
+
/**
|
|
86
|
+
* Extracts and normalizes the domain of an email address.
|
|
87
|
+
*/
|
|
88
|
+
export function getEmailAddressDomain(value: string): string {
|
|
89
|
+
const emailAddress = extractEmailAddress(value);
|
|
90
|
+
const separatorIndex = emailAddress.lastIndexOf('@');
|
|
91
|
+
|
|
92
|
+
if (separatorIndex === -1) {
|
|
93
|
+
return '';
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
return normalizeEmailDomain(emailAddress.slice(separatorIndex + 1));
|
|
97
|
+
}
|
|
98
|
+
|
|
85
99
|
/**
|
|
86
100
|
* Normalizes a mail domain for comparisons and generated addresses.
|
|
87
101
|
*/
|
|
@@ -4,6 +4,7 @@ import { parseEmailAddress } from '../../message-providers/email/_common/utils/p
|
|
|
4
4
|
import { createStalwartMessageProviderFromEnvironment } from '../../message-providers/email/stalwart/StalwartMessageProvider';
|
|
5
5
|
import { sendMessage } from '../messages/sendMessage';
|
|
6
6
|
import { synchronizeStalwartEmailDomain } from '../stalwart/synchronizeStalwartEmailDomain';
|
|
7
|
+
import { getEmailAddressDomain } from './agentEmailAddress';
|
|
7
8
|
|
|
8
9
|
/**
|
|
9
10
|
* Stable provider name stored with outbound Stalwart delivery attempts.
|
|
@@ -20,7 +21,7 @@ export async function sendEmailThroughStalwart(message: OutboundEmail): Promise<
|
|
|
20
21
|
}
|
|
21
22
|
|
|
22
23
|
const senderAddress = parseEmailAddress(message.sender).fullEmail;
|
|
23
|
-
const senderDomain =
|
|
24
|
+
const senderDomain = getEmailAddressDomain(senderAddress);
|
|
24
25
|
await synchronizeStalwartEmailDomain(senderDomain).catch((error) => {
|
|
25
26
|
console.error('[stalwart-email]', 'pre_delivery_domain_synchronization_failed', {
|
|
26
27
|
senderDomain,
|