@kodelyth/tlon 2026.5.42 → 2026.6.2

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.
Files changed (63) hide show
  1. package/klaw.plugin.json +203 -3
  2. package/package.json +19 -6
  3. package/api.ts +0 -16
  4. package/channel-plugin-api.ts +0 -1
  5. package/doctor-contract-api.ts +0 -1
  6. package/index.ts +0 -16
  7. package/runtime-api.ts +0 -17
  8. package/setup-api.ts +0 -2
  9. package/setup-entry.ts +0 -9
  10. package/src/account-fields.ts +0 -31
  11. package/src/channel.message-adapter.test.ts +0 -145
  12. package/src/channel.runtime.ts +0 -259
  13. package/src/channel.ts +0 -192
  14. package/src/config-schema.ts +0 -54
  15. package/src/core.test.ts +0 -298
  16. package/src/doctor-contract.ts +0 -9
  17. package/src/doctor.test.ts +0 -46
  18. package/src/doctor.ts +0 -10
  19. package/src/logger-runtime.ts +0 -1
  20. package/src/monitor/approval-runtime.ts +0 -363
  21. package/src/monitor/approval.test.ts +0 -33
  22. package/src/monitor/approval.ts +0 -283
  23. package/src/monitor/authorization.ts +0 -30
  24. package/src/monitor/cites.ts +0 -54
  25. package/src/monitor/discovery.ts +0 -68
  26. package/src/monitor/history.ts +0 -226
  27. package/src/monitor/index.ts +0 -1523
  28. package/src/monitor/media.test.ts +0 -80
  29. package/src/monitor/media.ts +0 -156
  30. package/src/monitor/processed-messages.test.ts +0 -58
  31. package/src/monitor/processed-messages.ts +0 -89
  32. package/src/monitor/settings-helpers.test.ts +0 -113
  33. package/src/monitor/settings-helpers.ts +0 -158
  34. package/src/monitor/utils.ts +0 -402
  35. package/src/runtime.ts +0 -9
  36. package/src/security.test.ts +0 -658
  37. package/src/session-route.ts +0 -40
  38. package/src/settings.ts +0 -391
  39. package/src/setup-core.ts +0 -231
  40. package/src/setup-surface.ts +0 -99
  41. package/src/targets.ts +0 -102
  42. package/src/tlon-api.test.ts +0 -572
  43. package/src/tlon-api.ts +0 -389
  44. package/src/types.ts +0 -160
  45. package/src/urbit/auth.ssrf.test.ts +0 -45
  46. package/src/urbit/auth.ts +0 -48
  47. package/src/urbit/base-url.test.ts +0 -48
  48. package/src/urbit/base-url.ts +0 -61
  49. package/src/urbit/channel-ops.test.ts +0 -36
  50. package/src/urbit/channel-ops.ts +0 -149
  51. package/src/urbit/context.ts +0 -50
  52. package/src/urbit/errors.ts +0 -51
  53. package/src/urbit/fetch.ts +0 -38
  54. package/src/urbit/foreigns.ts +0 -49
  55. package/src/urbit/send.test.ts +0 -83
  56. package/src/urbit/send.ts +0 -228
  57. package/src/urbit/sse-client.test.ts +0 -234
  58. package/src/urbit/sse-client.ts +0 -492
  59. package/src/urbit/story.ts +0 -332
  60. package/src/urbit/upload.test.ts +0 -155
  61. package/src/urbit/upload.ts +0 -60
  62. package/test-api.ts +0 -1
  63. package/tsconfig.json +0 -16
@@ -1,99 +0,0 @@
1
- import { createSetupTranslator } from "klaw/plugin-sdk/setup-runtime";
2
- import {
3
- applyTlonSetupConfig,
4
- createTlonSetupWizardBase,
5
- resolveTlonSetupConfigured,
6
- resolveTlonSetupStatusLines,
7
- } from "./setup-core.js";
8
- import { normalizeShip } from "./targets.js";
9
- import { resolveTlonAccount } from "./types.js";
10
- import { isBlockedUrbitHostname, validateUrbitBaseUrl } from "./urbit/base-url.js";
11
-
12
- const t = createSetupTranslator();
13
-
14
- function parseList(value: string): string[] {
15
- return value
16
- .split(/[\n,;]+/g)
17
- .map((entry) => entry.trim())
18
- .filter(Boolean);
19
- }
20
-
21
- export const tlonSetupWizard = createTlonSetupWizardBase({
22
- resolveConfigured: async ({ cfg, accountId }) => await resolveTlonSetupConfigured(cfg, accountId),
23
- resolveStatusLines: async ({ cfg, accountId }) =>
24
- await resolveTlonSetupStatusLines(cfg, accountId),
25
- finalize: async ({ cfg, accountId, prompter }) => {
26
- let next = cfg;
27
- const resolved = resolveTlonAccount(next, accountId);
28
- const validatedUrl = validateUrbitBaseUrl(resolved.url ?? "");
29
- if (!validatedUrl.ok) {
30
- throw new Error(`Invalid URL: ${validatedUrl.error}`);
31
- }
32
-
33
- let dangerouslyAllowPrivateNetwork = resolved.dangerouslyAllowPrivateNetwork ?? false;
34
- if (isBlockedUrbitHostname(validatedUrl.hostname)) {
35
- dangerouslyAllowPrivateNetwork = await prompter.confirm({
36
- message: t("wizard.tlon.privateNetworkPrompt"),
37
- initialValue: dangerouslyAllowPrivateNetwork,
38
- });
39
- if (!dangerouslyAllowPrivateNetwork) {
40
- throw new Error("Refusing private/internal ship URL without explicit network opt-in");
41
- }
42
- }
43
- next = applyTlonSetupConfig({
44
- cfg: next,
45
- accountId,
46
- input: { dangerouslyAllowPrivateNetwork },
47
- });
48
-
49
- const currentGroups = resolved.groupChannels;
50
- const wantsGroupChannels = await prompter.confirm({
51
- message: t("wizard.tlon.addGroupsPrompt"),
52
- initialValue: currentGroups.length > 0,
53
- });
54
- if (wantsGroupChannels) {
55
- const entry = await prompter.text({
56
- message: t("wizard.tlon.groupChannelsPrompt"),
57
- placeholder: "chat/~host-ship/general, chat/~host-ship/support",
58
- initialValue: currentGroups.join(", ") || undefined,
59
- });
60
- next = applyTlonSetupConfig({
61
- cfg: next,
62
- accountId,
63
- input: { groupChannels: parseList(entry ?? "") },
64
- });
65
- }
66
-
67
- const currentAllowlist = resolved.dmAllowlist;
68
- const wantsAllowlist = await prompter.confirm({
69
- message: t("wizard.tlon.restrictDmsPrompt"),
70
- initialValue: currentAllowlist.length > 0,
71
- });
72
- if (wantsAllowlist) {
73
- const entry = await prompter.text({
74
- message: t("wizard.tlon.dmAllowlistPrompt"),
75
- placeholder: "~zod, ~nec",
76
- initialValue: currentAllowlist.join(", ") || undefined,
77
- });
78
- next = applyTlonSetupConfig({
79
- cfg: next,
80
- accountId,
81
- input: {
82
- dmAllowlist: parseList(entry ?? "").map((ship) => normalizeShip(ship)),
83
- },
84
- });
85
- }
86
-
87
- const autoDiscoverChannels = await prompter.confirm({
88
- message: t("wizard.tlon.autoDiscoveryPrompt"),
89
- initialValue: resolved.autoDiscoverChannels ?? true,
90
- });
91
- next = applyTlonSetupConfig({
92
- cfg: next,
93
- accountId,
94
- input: { autoDiscoverChannels },
95
- });
96
-
97
- return { cfg: next };
98
- },
99
- });
package/src/targets.ts DELETED
@@ -1,102 +0,0 @@
1
- type TlonTarget =
2
- | { kind: "dm"; ship: string }
3
- | { kind: "group"; nest: string; hostShip: string; channelName: string };
4
-
5
- const SHIP_RE = /^~?[a-z-]+$/i;
6
- const NEST_RE = /^chat\/([^/]+)\/([^/]+)$/i;
7
-
8
- export function normalizeShip(raw: string): string {
9
- const trimmed = raw.trim();
10
- if (!trimmed) {
11
- return trimmed;
12
- }
13
- return trimmed.startsWith("~") ? trimmed : `~${trimmed}`;
14
- }
15
-
16
- export function parseChannelNest(raw: string): { hostShip: string; channelName: string } | null {
17
- const match = NEST_RE.exec(raw.trim());
18
- if (!match) {
19
- return null;
20
- }
21
- const hostShip = normalizeShip(match[1]);
22
- const channelName = match[2];
23
- return { hostShip, channelName };
24
- }
25
-
26
- function makeGroupTarget(parsed: { hostShip: string; channelName: string }): TlonTarget {
27
- return {
28
- kind: "group",
29
- nest: `chat/${parsed.hostShip}/${parsed.channelName}`,
30
- hostShip: parsed.hostShip,
31
- channelName: parsed.channelName,
32
- };
33
- }
34
-
35
- export function parseTlonTarget(raw?: string | null): TlonTarget | null {
36
- const trimmed = raw?.trim();
37
- if (!trimmed) {
38
- return null;
39
- }
40
- const withoutPrefix = trimmed.replace(/^tlon:/i, "");
41
-
42
- const dmPrefix = withoutPrefix.match(/^dm[/:](.+)$/i);
43
- if (dmPrefix) {
44
- return { kind: "dm", ship: normalizeShip(dmPrefix[1]) };
45
- }
46
-
47
- const groupPrefix = withoutPrefix.match(/^(group|room)[/:](.+)$/i);
48
- if (groupPrefix) {
49
- const groupTarget = groupPrefix[2].trim();
50
- if (groupTarget.startsWith("chat/")) {
51
- const parsed = parseChannelNest(groupTarget);
52
- if (!parsed) {
53
- return null;
54
- }
55
- return makeGroupTarget(parsed);
56
- }
57
- const parts = groupTarget.split("/");
58
- if (parts.length === 2) {
59
- const hostShip = normalizeShip(parts[0]);
60
- const channelName = parts[1];
61
- return {
62
- kind: "group",
63
- nest: `chat/${hostShip}/${channelName}`,
64
- hostShip,
65
- channelName,
66
- };
67
- }
68
- return null;
69
- }
70
-
71
- if (withoutPrefix.startsWith("chat/")) {
72
- const parsed = parseChannelNest(withoutPrefix);
73
- if (!parsed) {
74
- return null;
75
- }
76
- return makeGroupTarget(parsed);
77
- }
78
-
79
- if (SHIP_RE.test(withoutPrefix)) {
80
- return { kind: "dm", ship: normalizeShip(withoutPrefix) };
81
- }
82
-
83
- return null;
84
- }
85
-
86
- export function resolveTlonOutboundTarget(to?: string | null) {
87
- const parsed = parseTlonTarget(to ?? "");
88
- if (!parsed) {
89
- return {
90
- ok: false as const,
91
- error: new Error(`Invalid Tlon target. Use ${formatTargetHint()}`),
92
- };
93
- }
94
- if (parsed.kind === "dm") {
95
- return { ok: true as const, to: parsed.ship };
96
- }
97
- return { ok: true as const, to: parsed.nest };
98
- }
99
-
100
- export function formatTargetHint(): string {
101
- return "dm/~sampel-palnet | ~sampel-palnet | chat/~host-ship/channel | group:~host-ship/channel";
102
- }