Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ode",
"version": "0.0.90",
"version": "0.0.91",
"description": "Coding anywhere with your coding agents connected",
"module": "packages/core/index.ts",
"type": "module",
Expand Down
14 changes: 7 additions & 7 deletions packages/core/runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ export function createCoreRuntime(deps: RuntimeDeps) {

if (finalChunks.length > 1) {
if (statusFormat !== "aggressive" && !statusRateLimited) {
await runtimeDeps.im.updateMessage(channelId, statusTs, "Final result posted below in multiple messages.", false);
await runtimeDeps.im.updateMessage(channelId, statusTs, "Final result posted below in multiple messages.");
} else if (statusRateLimited) {
log.warn("Skipping final status update due to prior 429; posting final chunks as new messages", {
channelId,
Expand All @@ -163,13 +163,13 @@ export function createCoreRuntime(deps: RuntimeDeps) {
}

for (const chunk of finalChunks) {
await runtimeDeps.im.sendMessage(channelId, threadId, chunk, true);
await runtimeDeps.im.sendMessage(channelId, threadId, chunk);
}
return;
}

if (statusFormat === "aggressive") {
await runtimeDeps.im.sendMessage(channelId, threadId, singleChunk, true);
await runtimeDeps.im.sendMessage(channelId, threadId, singleChunk);
return;
}

Expand All @@ -180,18 +180,18 @@ export function createCoreRuntime(deps: RuntimeDeps) {
statusTs,
...(statusRateLimitError ? { error: statusRateLimitError } : {}),
});
await runtimeDeps.im.sendMessage(channelId, threadId, singleChunk, true);
await runtimeDeps.im.sendMessage(channelId, threadId, singleChunk);
return;
}

const maxEditableMessageChars = runtimeDeps.im.maxEditableMessageChars;
if (typeof maxEditableMessageChars === "number" && singleChunk.length > maxEditableMessageChars) {
await runtimeDeps.im.updateMessage(channelId, statusTs, "Final result posted below.", false);
await runtimeDeps.im.sendMessage(channelId, threadId, singleChunk, true);
await runtimeDeps.im.updateMessage(channelId, statusTs, "Final result posted below.");
await runtimeDeps.im.sendMessage(channelId, threadId, singleChunk);
return;
}

await runtimeDeps.im.updateMessage(channelId, statusTs, singleChunk, true);
await runtimeDeps.im.updateMessage(channelId, statusTs, singleChunk);
}

async function handleUserMessageInternal(context: CoreMessageContext, text: string): Promise<void> {
Expand Down
3 changes: 1 addition & 2 deletions packages/core/runtime/event-stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,7 @@ export async function startEventStreamWatcher(
workingPath,
state: liveParsedState.get(messageKey),
statusMessageFormat: resolveStatusMessageFormat(),
}),
false
})
);
if (typeof updatedStatusTs === "string" && updatedStatusTs !== request.statusMessageTs) {
request.statusMessageTs = updatedStatusTs;
Expand Down
8 changes: 3 additions & 5 deletions packages/core/runtime/message-updates.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ type QueuedUpdate = {
channelId: string;
messageTs: string;
text: string;
asMarkdown: boolean;
resolve: (messageTs?: string) => void;
};

Expand Down Expand Up @@ -44,7 +43,7 @@ export function createRateLimitedImAdapter(

globalLastUpdateAt = Date.now();
try {
const maybeUpdatedTs = await im.updateMessage(item.channelId, item.messageTs, item.text, item.asMarkdown);
const maybeUpdatedTs = await im.updateMessage(item.channelId, item.messageTs, item.text);
item.resolve(typeof maybeUpdatedTs === "string" ? maybeUpdatedTs : undefined);
} catch (error) {
if (isRateLimitError(error)) {
Expand Down Expand Up @@ -87,8 +86,7 @@ export function createRateLimitedImAdapter(
updateMessage: async (
channelId: string,
messageTs: string,
text: string,
asMarkdown = true
text: string
): Promise<string | undefined> => {
for (let i = queue.length - 1; i >= 0; i--) {
const queued = queue[i];
Expand All @@ -99,7 +97,7 @@ export function createRateLimitedImAdapter(
}

return new Promise<string | undefined>((resolve) => {
queue.push({ channelId, messageTs, text, asMarkdown, resolve });
queue.push({ channelId, messageTs, text, resolve });
void processQueue();
});
},
Expand Down
5 changes: 2 additions & 3 deletions packages/core/runtime/open-request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,7 @@ export async function runOpenRequest(params: {
const initialStatusTs = await deps.im.sendMessage(
context.channelId,
context.replyThreadId,
`${providerLabel} is running...`,
false
`${providerLabel} is running...`
);

if (!initialStatusTs) {
Expand Down Expand Up @@ -126,7 +125,7 @@ export async function runOpenRequest(params: {
statusMessageFormat: resolveStatusMessageFormat(),
});
if (!request.statusFrozen) {
const updatedStatusTs = await deps.im.updateMessage(context.channelId, statusTs, statusText, false);
const updatedStatusTs = await deps.im.updateMessage(context.channelId, statusTs, statusText);
if (typeof updatedStatusTs === "string" && updatedStatusTs !== statusTs) {
statusTs = updatedStatusTs;
request.statusMessageTs = updatedStatusTs;
Expand Down
5 changes: 2 additions & 3 deletions packages/core/runtime/pending-question.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export async function handlePendingQuestionReply(params: {

const trimmed = text.trim();
if (!trimmed) {
await deps.im.sendMessage(context.channelId, context.replyThreadId, "Please reply with an answer.", false);
await deps.im.sendMessage(context.channelId, context.replyThreadId, "Please reply with an answer.");
return true;
}

Expand All @@ -54,8 +54,7 @@ export async function handlePendingQuestionReply(params: {
await deps.im.sendMessage(
context.channelId,
context.replyThreadId,
"Failed to submit your answer. Please try again.",
false
"Failed to submit your answer. Please try again."
);
return true;
}
Expand Down
3 changes: 1 addition & 2 deletions packages/core/runtime/recovery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@ export async function recoverPendingRequests(
await im.updateMessage(
request.channelId,
request.statusMessageTs,
"_Bot restarted - please resend your message_",
false
"_Bot restarted - please resend your message_"
);

clearActiveRequest(session.channelId, session.threadId);
Expand Down
2 changes: 1 addition & 1 deletion packages/core/runtime/request-runner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ export async function runTrackedRequest(
liveParsedState.delete(getStatusMessageKey(request));

const errorStatus = `Error: ${message}\n_${suggestion}_`;
await deps.im.updateMessage(request.channelId, request.statusMessageTs, errorStatus, false);
await deps.im.updateMessage(request.channelId, request.statusMessageTs, errorStatus);
onFail(message);
return { responses: null };
}
Expand Down
4 changes: 2 additions & 2 deletions packages/core/runtime/selection-reply.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ export async function handleSelectionReply(params: HandleSelectionReplyParams):
const providerId = deps.agent.getProviderForSession(sessionId);
const providerLabel = deps.agent.getDisplayNameForSession(sessionId);

const initialStatusTs = await deps.im.sendMessage(channelId, threadId, `${providerLabel} is running...`, false);
const initialStatusTs = await deps.im.sendMessage(channelId, threadId, `${providerLabel} is running...`);
if (!initialStatusTs) {
log.error("Failed to send status message for button selection");
return;
Expand Down Expand Up @@ -142,7 +142,7 @@ export async function handleSelectionReply(params: HandleSelectionReplyParams):
state: state.liveParsedState.get(statusMessageKey),
statusMessageFormat: resolveStatusMessageFormat(),
});
const updatedStatusTs = await deps.im.updateMessage(channelId, statusTs, statusText, false);
const updatedStatusTs = await deps.im.updateMessage(channelId, statusTs, statusText);
if (typeof updatedStatusTs === "string" && updatedStatusTs !== statusTs) {
statusTs = updatedStatusTs;
request.statusMessageTs = updatedStatusTs;
Expand Down
8 changes: 4 additions & 4 deletions packages/core/runtime/session-bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export async function prepareRuntimeSession(params: {
try {
cwd = resolveChannelCwd(channelId).cwd;
} catch (err) {
await deps.im.sendMessage(channelId, replyThreadId, `Error: ${String(err)}`, false);
await deps.im.sendMessage(channelId, replyThreadId, `Error: ${String(err)}`);
return null;
}

Expand All @@ -55,7 +55,7 @@ export async function prepareRuntimeSession(params: {
threadId,
error: String(err),
});
await deps.im.sendMessage(channelId, replyThreadId, `Error: ${message}\n_${suggestion}_`, false);
await deps.im.sendMessage(channelId, replyThreadId, `Error: ${message}\n_${suggestion}_`);
return null;
}

Expand All @@ -74,7 +74,7 @@ export async function prepareRuntimeSession(params: {
gitIdentity,
});
if (worktree.skipped && worktree.message) {
await deps.im.sendMessage(channelId, replyThreadId, worktree.message, false);
await deps.im.sendMessage(channelId, replyThreadId, worktree.message);
}
cwd = resolvedCwd;
} catch (err) {
Expand All @@ -85,7 +85,7 @@ export async function prepareRuntimeSession(params: {
sessionId,
error: message,
});
await deps.im.sendMessage(channelId, replyThreadId, `Error: Failed to prepare worktree. ${message}`, false);
await deps.im.sendMessage(channelId, replyThreadId, `Error: Failed to prepare worktree. ${message}`);
return null;
}
}
Expand Down
5 changes: 2 additions & 3 deletions packages/core/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,11 @@ export type AgentStatusMessageParams = {

export interface IMAdapter {
maxEditableMessageChars?: number;
sendMessage(channelId: string, threadId: string, text: string, asMarkdown?: boolean): Promise<string | undefined>;
sendMessage(channelId: string, threadId: string, text: string): Promise<string | undefined>;
updateMessage(
channelId: string,
messageTs: string,
text: string,
asMarkdown?: boolean
text: string
): Promise<string | undefined | void>;
wasRateLimited?(channelId: string, messageTs: string): boolean;
getRateLimitError?(channelId: string, messageTs: string): string | undefined;
Expand Down
6 changes: 2 additions & 4 deletions packages/ims/discord/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,7 @@ async function buildDiscordContext(
async function sendMessage(
_channelId: string,
threadId: string,
text: string,
_asMarkdown = true
text: string
): Promise<string | undefined> {
const channel = await resolveTextChannel(threadId);
const chunks = splitForDiscord(text);
Expand All @@ -106,8 +105,7 @@ async function sendMessage(
async function updateMessage(
channelId: string,
messageId: string,
text: string,
_asMarkdown = true
text: string
): Promise<void> {
try {
const mappedThreadId = statusMessageThreadMap.get(messageId);
Expand Down
Loading