Merge ddc29261c2 into 4583f88626
This commit is contained in:
commit
1e3d2cfa98
@ -17,6 +17,48 @@ import { buildMediaText, sendDm, sendGroupMessage } from "./urbit/send.js";
|
|||||||
import { monitorTlonProvider } from "./monitor/index.js";
|
import { monitorTlonProvider } from "./monitor/index.js";
|
||||||
import { tlonChannelConfigSchema } from "./config-schema.js";
|
import { tlonChannelConfigSchema } from "./config-schema.js";
|
||||||
import { tlonOnboardingAdapter } from "./onboarding.js";
|
import { tlonOnboardingAdapter } from "./onboarding.js";
|
||||||
|
import { authenticate } from "./urbit/auth.js";
|
||||||
|
|
||||||
|
// Simple HTTP-only poke that doesn't open an EventSource (avoids conflict with monitor's SSE)
|
||||||
|
async function createHttpPokeApi(params: { url: string; code: string; ship: string }) {
|
||||||
|
const cookie = await authenticate(params.url, params.code);
|
||||||
|
const channelId = `${Math.floor(Date.now() / 1000)}-${Math.random().toString(36).substring(2, 8)}`;
|
||||||
|
const channelUrl = `${params.url}/~/channel/${channelId}`;
|
||||||
|
const shipName = params.ship.replace(/^~/, "");
|
||||||
|
|
||||||
|
return {
|
||||||
|
poke: async (pokeParams: { app: string; mark: string; json: unknown }) => {
|
||||||
|
const pokeId = Date.now();
|
||||||
|
const pokeData = {
|
||||||
|
id: pokeId,
|
||||||
|
action: "poke",
|
||||||
|
ship: shipName,
|
||||||
|
app: pokeParams.app,
|
||||||
|
mark: pokeParams.mark,
|
||||||
|
json: pokeParams.json,
|
||||||
|
};
|
||||||
|
|
||||||
|
const response = await fetch(channelUrl, {
|
||||||
|
method: "PUT",
|
||||||
|
headers: {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
Cookie: cookie.split(";")[0],
|
||||||
|
},
|
||||||
|
body: JSON.stringify([pokeData]),
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!response.ok && response.status !== 204) {
|
||||||
|
const errorText = await response.text();
|
||||||
|
throw new Error(`Poke failed: ${response.status} - ${errorText}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
return pokeId;
|
||||||
|
},
|
||||||
|
delete: async () => {
|
||||||
|
// No-op for HTTP-only client
|
||||||
|
},
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
const TLON_CHANNEL_ID = "tlon" as const;
|
const TLON_CHANNEL_ID = "tlon" as const;
|
||||||
|
|
||||||
@ -118,12 +160,11 @@ const tlonOutbound: ChannelOutboundAdapter = {
|
|||||||
throw new Error(`Invalid Tlon target. Use ${formatTargetHint()}`);
|
throw new Error(`Invalid Tlon target. Use ${formatTargetHint()}`);
|
||||||
}
|
}
|
||||||
|
|
||||||
ensureUrbitConnectPatched();
|
// Use HTTP-only poke (no EventSource) to avoid conflicts with monitor's SSE connection
|
||||||
const api = await Urbit.authenticate({
|
const api = await createHttpPokeApi({
|
||||||
ship: account.ship.replace(/^~/, ""),
|
|
||||||
url: account.url,
|
url: account.url,
|
||||||
|
ship: account.ship,
|
||||||
code: account.code,
|
code: account.code,
|
||||||
verbose: false,
|
|
||||||
});
|
});
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user