mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-06 08:50:43 +00:00
refactor: trim tlon helper exports
This commit is contained in:
@@ -2,7 +2,7 @@ import type { RuntimeEnv } from "openclaw/plugin-sdk/runtime";
|
||||
import type { Foreigns } from "../urbit/foreigns.js";
|
||||
import { asRecord, formatErrorMessage } from "./utils.js";
|
||||
|
||||
export interface InitData {
|
||||
interface InitData {
|
||||
channels: string[];
|
||||
foreigns: Foreigns | null;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@ function formatUd(id: string | number): string {
|
||||
return chunks.toReversed().join(".");
|
||||
}
|
||||
|
||||
export type TlonHistoryEntry = {
|
||||
type TlonHistoryEntry = {
|
||||
author: string;
|
||||
content: string;
|
||||
timestamp: number;
|
||||
@@ -63,7 +63,7 @@ export function cacheMessage(channelNest: string, message: TlonHistoryEntry) {
|
||||
}
|
||||
}
|
||||
|
||||
export async function fetchChannelHistory(
|
||||
async function fetchChannelHistory(
|
||||
api: { scry: (path: string) => Promise<unknown> },
|
||||
channelNest: string,
|
||||
count = 50,
|
||||
|
||||
@@ -45,7 +45,7 @@ import {
|
||||
stripBotMention,
|
||||
} from "./utils.js";
|
||||
|
||||
export type MonitorTlonOpts = {
|
||||
type MonitorTlonOpts = {
|
||||
runtime?: RuntimeEnv;
|
||||
abortSignal?: AbortSignal;
|
||||
accountId?: string | null;
|
||||
|
||||
@@ -13,12 +13,12 @@ import { getDefaultSsrFPolicy } from "../urbit/context.js";
|
||||
const MAX_IMAGES_PER_MESSAGE = 8;
|
||||
const TLON_MEDIA_DOWNLOAD_IDLE_TIMEOUT_MS = 30_000;
|
||||
|
||||
export interface ExtractedImage {
|
||||
interface ExtractedImage {
|
||||
url: string;
|
||||
alt?: string;
|
||||
}
|
||||
|
||||
export interface DownloadedMedia {
|
||||
interface DownloadedMedia {
|
||||
localPath: string;
|
||||
contentType: string;
|
||||
originalUrl: string;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { createDedupeCache } from "../../runtime-api.js";
|
||||
|
||||
export type ProcessedMessageTracker = {
|
||||
type ProcessedMessageTracker = {
|
||||
claim: (id?: string | null) => { kind: "claimed" } | { kind: "duplicate" };
|
||||
commit: (id?: string | null) => void;
|
||||
release: (id?: string | null) => void;
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { PendingApproval, TlonSettingsStore } from "../settings.js";
|
||||
import { normalizeShip } from "../targets.js";
|
||||
import type { TlonResolvedAccount } from "../types.js";
|
||||
|
||||
export type TlonMonitorSettingsState = {
|
||||
type TlonMonitorSettingsState = {
|
||||
effectiveDmAllowlist: string[];
|
||||
effectiveShowModelSig: boolean;
|
||||
effectiveAutoAcceptDmInvites: boolean;
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { LookupFn, SsrFPolicy } from "openclaw/plugin-sdk/ssrf-runtime";
|
||||
import { UrbitAuthError } from "./errors.js";
|
||||
import { urbitFetch } from "./fetch.js";
|
||||
|
||||
export type UrbitAuthenticateOptions = {
|
||||
type UrbitAuthenticateOptions = {
|
||||
ssrfPolicy?: SsrFPolicy;
|
||||
lookupFn?: LookupFn;
|
||||
fetchImpl?: (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { isBlockedHostnameOrIp } from "openclaw/plugin-sdk/ssrf-runtime";
|
||||
|
||||
export type UrbitBaseUrlValidation =
|
||||
type UrbitBaseUrlValidation =
|
||||
| { ok: true; baseUrl: string; hostname: string }
|
||||
| { ok: false; error: string };
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import type { LookupFn, SsrFPolicy } from "openclaw/plugin-sdk/ssrf-runtime";
|
||||
import { UrbitHttpError } from "./errors.js";
|
||||
import { urbitFetch } from "./fetch.js";
|
||||
|
||||
export type UrbitChannelDeps = {
|
||||
type UrbitChannelDeps = {
|
||||
baseUrl: string;
|
||||
cookie: string;
|
||||
ship: string;
|
||||
@@ -94,7 +94,7 @@ export async function scryUrbitPath(
|
||||
}
|
||||
}
|
||||
|
||||
export async function createUrbitChannel(
|
||||
async function createUrbitChannel(
|
||||
deps: UrbitChannelDeps,
|
||||
params: { body: unknown; auditContext: string },
|
||||
): Promise<void> {
|
||||
@@ -109,7 +109,7 @@ export async function createUrbitChannel(
|
||||
}
|
||||
}
|
||||
|
||||
export async function wakeUrbitChannel(deps: UrbitChannelDeps): Promise<void> {
|
||||
async function wakeUrbitChannel(deps: UrbitChannelDeps): Promise<void> {
|
||||
const { response, release } = await putUrbitChannel(deps, {
|
||||
body: [
|
||||
{
|
||||
|
||||
@@ -2,13 +2,13 @@ export { ssrfPolicyFromDangerouslyAllowPrivateNetwork } from "openclaw/plugin-sd
|
||||
import { normalizeUrbitHostname, validateUrbitBaseUrl } from "./base-url.js";
|
||||
import { UrbitUrlError } from "./errors.js";
|
||||
|
||||
export type UrbitContext = {
|
||||
type UrbitContext = {
|
||||
baseUrl: string;
|
||||
hostname: string;
|
||||
ship: string;
|
||||
};
|
||||
|
||||
export function resolveShipFromHostname(hostname: string): string {
|
||||
function resolveShipFromHostname(hostname: string): string {
|
||||
const trimmed = normalizeUrbitHostname(hostname);
|
||||
if (!trimmed) {
|
||||
return "";
|
||||
@@ -19,7 +19,7 @@ export function resolveShipFromHostname(hostname: string): string {
|
||||
return trimmed;
|
||||
}
|
||||
|
||||
export function normalizeUrbitShip(ship: string | undefined, hostname: string): string {
|
||||
function normalizeUrbitShip(ship: string | undefined, hostname: string): string {
|
||||
const raw = ship?.replace(/^~/, "") ?? resolveShipFromHostname(hostname);
|
||||
return raw.trim();
|
||||
}
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
export type UrbitErrorCode =
|
||||
type UrbitErrorCode =
|
||||
| "invalid_url"
|
||||
| "http_error"
|
||||
| "auth_failed"
|
||||
| "missing_cookie"
|
||||
| "channel_not_open";
|
||||
|
||||
export class UrbitError extends Error {
|
||||
class UrbitError extends Error {
|
||||
readonly code: UrbitErrorCode;
|
||||
|
||||
constructor(code: UrbitErrorCode, message: string, options?: { cause?: unknown }) {
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
import { validateUrbitBaseUrl } from "./base-url.js";
|
||||
import { UrbitUrlError } from "./errors.js";
|
||||
|
||||
export type UrbitFetchOptions = {
|
||||
type UrbitFetchOptions = {
|
||||
baseUrl: string;
|
||||
path: string;
|
||||
init?: RequestInit;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* Based on packages/shared/src/urbit/groups.ts from homestead
|
||||
*/
|
||||
|
||||
export interface GroupPreviewV7 {
|
||||
interface GroupPreviewV7 {
|
||||
meta: {
|
||||
title: string;
|
||||
description: string;
|
||||
@@ -17,7 +17,7 @@ export interface GroupPreviewV7 {
|
||||
};
|
||||
}
|
||||
|
||||
export interface ForeignInvite {
|
||||
interface ForeignInvite {
|
||||
flag: string; // group flag e.g. "~host/group-name"
|
||||
time: number; // timestamp
|
||||
from: string; // ship that sent invite
|
||||
@@ -27,10 +27,10 @@ export interface ForeignInvite {
|
||||
valid: boolean; // tracks if invite has been revoked
|
||||
}
|
||||
|
||||
export type Lookup = "preview" | "done" | "error";
|
||||
export type Progress = "ask" | "join" | "watch" | "done" | "error";
|
||||
type Lookup = "preview" | "done" | "error";
|
||||
type Progress = "ask" | "join" | "watch" | "done" | "error";
|
||||
|
||||
export interface Foreign {
|
||||
interface Foreign {
|
||||
invites: ForeignInvite[];
|
||||
lookup: Lookup | null;
|
||||
preview: GroupPreviewV7 | null;
|
||||
|
||||
@@ -5,7 +5,7 @@ import { ensureUrbitChannelOpen, pokeUrbitChannel, scryUrbitPath } from "./chann
|
||||
import { getUrbitContext, normalizeUrbitCookie } from "./context.js";
|
||||
import { urbitFetch } from "./fetch.js";
|
||||
|
||||
export type UrbitSseLogger = {
|
||||
type UrbitSseLogger = {
|
||||
log?: (message: string) => void;
|
||||
error?: (message: string) => void;
|
||||
};
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
// Inline content types
|
||||
export type StoryInline =
|
||||
type StoryInline =
|
||||
| string
|
||||
| { bold: StoryInline[] }
|
||||
| { italics: StoryInline[] }
|
||||
@@ -19,14 +19,14 @@ export type StoryInline =
|
||||
| { tag: string };
|
||||
|
||||
// Block content types
|
||||
export type StoryBlock =
|
||||
type StoryBlock =
|
||||
| { header: { tag: "h1" | "h2" | "h3" | "h4" | "h5" | "h6"; content: StoryInline[] } }
|
||||
| { code: { code: string; lang: string } }
|
||||
| { image: { src: string; height: number; width: number; alt: string } }
|
||||
| { rule: null }
|
||||
| { listing: StoryListing };
|
||||
|
||||
export type StoryListing =
|
||||
type StoryListing =
|
||||
| {
|
||||
list: {
|
||||
type: "ordered" | "unordered" | "tasklist";
|
||||
@@ -37,7 +37,7 @@ export type StoryListing =
|
||||
| { item: StoryInline[] };
|
||||
|
||||
// A verse is either a block or inline content
|
||||
export type StoryVerse = { block: StoryBlock } | { inline: StoryInline[] };
|
||||
type StoryVerse = { block: StoryBlock } | { inline: StoryInline[] };
|
||||
|
||||
// A story is a list of verses
|
||||
export type Story = StoryVerse[];
|
||||
|
||||
Reference in New Issue
Block a user