codex-relay 1.4.3 → 1.4.4
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/dist/api-schema2.js +1 -0
- package/dist/src.js +19 -6
- package/package.json +1 -1
- package/src/api-schema.ts +1 -0
package/dist/api-schema2.js
CHANGED
|
@@ -268,6 +268,7 @@ const ChatMessageSchema = z.object({
|
|
|
268
268
|
});
|
|
269
269
|
const ThreadSummarySchema = z.object({
|
|
270
270
|
id: z.string().min(1),
|
|
271
|
+
parentThreadId: z.string().min(1).optional(),
|
|
271
272
|
title: z.string().min(1),
|
|
272
273
|
createdAt: IsoDateTimeSchema,
|
|
273
274
|
updatedAt: IsoDateTimeSchema,
|
package/dist/src.js
CHANGED
|
@@ -2106,7 +2106,7 @@ function createApp(options = {}) {
|
|
|
2106
2106
|
if (appServer) try {
|
|
2107
2107
|
const appServerThreads = await appServer.listThreads();
|
|
2108
2108
|
const response = ListThreadsResponseSchema.parse({
|
|
2109
|
-
threads: appServerThreads.map((thread) => rememberAppServerThread(threads, thread)),
|
|
2109
|
+
threads: appServerThreads.filter((thread) => !isSubagentThread(thread)).map((thread) => rememberAppServerThread(threads, thread)),
|
|
2110
2110
|
source: "app-server"
|
|
2111
2111
|
});
|
|
2112
2112
|
return secureJson(c, options.pairing, secureSessionsByTokenHash, response);
|
|
@@ -2129,7 +2129,7 @@ function createApp(options = {}) {
|
|
|
2129
2129
|
const appServerThreads = await appServer.listThreads();
|
|
2130
2130
|
const response = ArchiveThreadResponseSchema.parse({
|
|
2131
2131
|
archivedThreadId: threadId,
|
|
2132
|
-
threads: appServerThreads.map((thread) => rememberAppServerThread(threads, thread)),
|
|
2132
|
+
threads: appServerThreads.filter((thread) => !isSubagentThread(thread)).map((thread) => rememberAppServerThread(threads, thread)),
|
|
2133
2133
|
source: "app-server"
|
|
2134
2134
|
});
|
|
2135
2135
|
return secureJson(c, options.pairing, secureSessionsByTokenHash, response);
|
|
@@ -2156,9 +2156,12 @@ function createApp(options = {}) {
|
|
|
2156
2156
|
const detailStartedAt = Date.now();
|
|
2157
2157
|
relayDebugLog("thread.detail.requested", { threadId });
|
|
2158
2158
|
const knownThread = threads.get(threadId);
|
|
2159
|
+
if (knownThread && isSubagentThread(knownThread)) return secureJson(c, options.pairing, secureSessionsByTokenHash, apiError("not_found", `Thread ${threadId} is not known to this server.`), 404);
|
|
2159
2160
|
const wasKnownRunning = knownThread?.state === "running" || activeAppServerTurnIdsByThreadId.has(threadId);
|
|
2160
2161
|
if (appServer) try {
|
|
2161
|
-
const
|
|
2162
|
+
const thread = await appServer.readThread(threadId, { includeTurns: false });
|
|
2163
|
+
if (isSubagentThread(thread)) return secureJson(c, options.pairing, secureSessionsByTokenHash, apiError("not_found", `Thread ${threadId} is not known to this server.`), 404);
|
|
2164
|
+
const mappedThread = rememberAppServerThread(threads, thread);
|
|
2162
2165
|
const cachedMessages = messagesByThreadId.get(threadId) ?? [];
|
|
2163
2166
|
let loadedMessages = false;
|
|
2164
2167
|
let messages = cachedMessages;
|
|
@@ -4099,14 +4102,15 @@ function createSecureSessionHandle(pairing, tokenHash, session) {
|
|
|
4099
4102
|
};
|
|
4100
4103
|
}
|
|
4101
4104
|
function sortedThreads(threads) {
|
|
4102
|
-
return [...threads.values()].sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
|
4105
|
+
return [...threads.values()].filter((thread) => !isSubagentThread(thread)).sort((a, b) => b.updatedAt.localeCompare(a.updatedAt));
|
|
4103
4106
|
}
|
|
4104
4107
|
async function ensureKnownThread(input) {
|
|
4105
4108
|
const knownThread = input.threads.get(input.threadId);
|
|
4106
|
-
if (knownThread) return knownThread;
|
|
4109
|
+
if (knownThread) return isSubagentThread(knownThread) ? void 0 : knownThread;
|
|
4107
4110
|
if (!input.appServer) return;
|
|
4108
4111
|
try {
|
|
4109
4112
|
const appServerThread = await input.appServer.readThread(input.threadId, { includeTurns: false });
|
|
4113
|
+
if (isSubagentThread(appServerThread)) return;
|
|
4110
4114
|
return rememberAppServerThread(input.threads, appServerThread);
|
|
4111
4115
|
} catch {
|
|
4112
4116
|
return;
|
|
@@ -4846,6 +4850,7 @@ function mapAppServerThread(thread, fallbackMessageCount) {
|
|
|
4846
4850
|
const mappedState = mapAppServerThreadState(thread.status, thread.turns);
|
|
4847
4851
|
return ThreadSummarySchema.parse({
|
|
4848
4852
|
id: thread.id,
|
|
4853
|
+
parentThreadId: thread.parentThreadId ?? void 0,
|
|
4849
4854
|
title: thread.name ?? preview(thread.preview || "Untitled thread"),
|
|
4850
4855
|
createdAt,
|
|
4851
4856
|
updatedAt,
|
|
@@ -4869,6 +4874,9 @@ function rememberAppServerThread(threads, thread) {
|
|
|
4869
4874
|
threads.set(threadWithLocalRuntime.id, threadWithLocalRuntime);
|
|
4870
4875
|
return threadWithLocalRuntime;
|
|
4871
4876
|
}
|
|
4877
|
+
function isSubagentThread(thread) {
|
|
4878
|
+
return Boolean(thread.parentThreadId);
|
|
4879
|
+
}
|
|
4872
4880
|
function mapAppServerThreadGoal(goal) {
|
|
4873
4881
|
if (!goal) return null;
|
|
4874
4882
|
return ThreadGoalSchema.parse({
|
|
@@ -5859,7 +5867,12 @@ function observeAppServerPushNotifications(appServer, dispatcher) {
|
|
|
5859
5867
|
appServer.onRequest((request) => {
|
|
5860
5868
|
const event = pushNotificationEventFromApprovalRequest(request);
|
|
5861
5869
|
if (!event) return;
|
|
5862
|
-
|
|
5870
|
+
const eventId = `${event.intent}:${event.threadId}:${event.turnId ?? ""}:${request.id}`;
|
|
5871
|
+
if (subagentThreadIds.has(event.threadId)) {
|
|
5872
|
+
rememberEventId(eventId);
|
|
5873
|
+
return;
|
|
5874
|
+
}
|
|
5875
|
+
dispatch(event, eventId);
|
|
5863
5876
|
});
|
|
5864
5877
|
}
|
|
5865
5878
|
function rememberSubagentThreadIds(notification, subagentThreadIds) {
|
package/package.json
CHANGED
package/src/api-schema.ts
CHANGED
|
@@ -304,6 +304,7 @@ export const ChatMessageSchema = z.object({
|
|
|
304
304
|
|
|
305
305
|
export const ThreadSummarySchema = z.object({
|
|
306
306
|
id: z.string().min(1),
|
|
307
|
+
parentThreadId: z.string().min(1).optional(),
|
|
307
308
|
title: z.string().min(1),
|
|
308
309
|
createdAt: IsoDateTimeSchema,
|
|
309
310
|
updatedAt: IsoDateTimeSchema,
|