@tenonai/yew 0.0.0-stage → 1.4.0

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 (133) hide show
  1. package/CHANGELOG.md +296 -0
  2. package/LICENSE +21 -0
  3. package/README.md +55 -2
  4. package/THIRD-PARTY-NOTICES.md +122 -0
  5. package/bin/yew.js +9 -0
  6. package/dist/cli/app.js +198 -0
  7. package/dist/cli/export.js +57 -0
  8. package/dist/cli/io.js +65 -0
  9. package/dist/cli/key.js +113 -0
  10. package/dist/cli/main.js +44 -0
  11. package/dist/cli/mcp.js +76 -0
  12. package/dist/cli/remote.js +116 -0
  13. package/dist/cli/run.js +72 -0
  14. package/dist/cli/schedule.js +123 -0
  15. package/dist/cli/send.js +126 -0
  16. package/dist/cli/serve.js +301 -0
  17. package/dist/cli/service.js +241 -0
  18. package/dist/cli/system.js +44 -0
  19. package/dist/remote/access.js +107 -0
  20. package/dist/remote/connector.js +278 -0
  21. package/dist/remote/identity.js +71 -0
  22. package/dist/remote/noise.js +287 -0
  23. package/dist/remote/protocol.js +51 -0
  24. package/dist/remote/push.js +37 -0
  25. package/dist/server/agent/compaction.js +242 -0
  26. package/dist/server/agent/context.js +119 -0
  27. package/dist/server/agent/held.js +48 -0
  28. package/dist/server/agent/helper.js +122 -0
  29. package/dist/server/agent/mailroom.js +510 -0
  30. package/dist/server/agent/prompt.js +268 -0
  31. package/dist/server/agent/runner.js +1159 -0
  32. package/dist/server/artifacts.js +216 -0
  33. package/dist/server/budget.js +88 -0
  34. package/dist/server/data-export.js +105 -0
  35. package/dist/server/data-usage.js +143 -0
  36. package/dist/server/db/database.js +49 -0
  37. package/dist/server/db/migrations.js +347 -0
  38. package/dist/server/errors.js +16 -0
  39. package/dist/server/events.js +17 -0
  40. package/dist/server/export.js +378 -0
  41. package/dist/server/folder-picker.js +32 -0
  42. package/dist/server/from-jig.js +98 -0
  43. package/dist/server/http/agents.js +78 -0
  44. package/dist/server/http/api.js +468 -0
  45. package/dist/server/http/app.js +111 -0
  46. package/dist/server/http/artifacts.js +53 -0
  47. package/dist/server/http/data.js +54 -0
  48. package/dist/server/http/devices.js +47 -0
  49. package/dist/server/http/events.js +134 -0
  50. package/dist/server/http/idempotency.js +53 -0
  51. package/dist/server/http/input.js +106 -0
  52. package/dist/server/http/mail.js +52 -0
  53. package/dist/server/http/mcp.js +134 -0
  54. package/dist/server/http/notes.js +91 -0
  55. package/dist/server/http/problem.js +55 -0
  56. package/dist/server/http/providers.js +131 -0
  57. package/dist/server/http/schedules.js +58 -0
  58. package/dist/server/http/search.js +42 -0
  59. package/dist/server/http/security.js +168 -0
  60. package/dist/server/http/skills.js +53 -0
  61. package/dist/server/http/system.js +26 -0
  62. package/dist/server/ids.js +30 -0
  63. package/dist/server/keys.js +51 -0
  64. package/dist/server/mail/envelope.js +152 -0
  65. package/dist/server/mail/post.js +603 -0
  66. package/dist/server/mail/store.js +279 -0
  67. package/dist/server/manage.js +601 -0
  68. package/dist/server/mcp-builtin.js +179 -0
  69. package/dist/server/mcp-config.js +305 -0
  70. package/dist/server/mcp-oauth.js +448 -0
  71. package/dist/server/mcp.js +668 -0
  72. package/dist/server/model/gateway.js +410 -0
  73. package/dist/server/paths.js +34 -0
  74. package/dist/server/permissions/engine.js +249 -0
  75. package/dist/server/permissions/paths.js +93 -0
  76. package/dist/server/permissions/shell.js +635 -0
  77. package/dist/server/push.js +345 -0
  78. package/dist/server/reveal.js +36 -0
  79. package/dist/server/runtime.js +17 -0
  80. package/dist/server/schedules.js +356 -0
  81. package/dist/server/settings.js +80 -0
  82. package/dist/server/skills.js +262 -0
  83. package/dist/server/store.js +1077 -0
  84. package/dist/server/tools/files.js +318 -0
  85. package/dist/server/tools/html.js +221 -0
  86. package/dist/server/tools/jobs.js +38 -0
  87. package/dist/server/tools/mail.js +680 -0
  88. package/dist/server/tools/match.js +81 -0
  89. package/dist/server/tools/misc.js +253 -0
  90. package/dist/server/tools/process.js +128 -0
  91. package/dist/server/tools/read-state.js +40 -0
  92. package/dist/server/tools/registry.js +43 -0
  93. package/dist/server/tools/search.js +175 -0
  94. package/dist/server/tools/shell.js +124 -0
  95. package/dist/server/tools/types.js +43 -0
  96. package/dist/server/tools/web-search.js +198 -0
  97. package/dist/server/tools/web.js +240 -0
  98. package/dist/shared/cron.js +105 -0
  99. package/dist/shared/mcp-presets.js +170 -0
  100. package/dist/shared/messages.js +45 -0
  101. package/dist/shared/policy.js +42 -0
  102. package/dist/shared/types.js +34 -0
  103. package/dist/shared/version.js +8 -0
  104. package/mcp-builtin/package-lock.json +3398 -0
  105. package/mcp-builtin/package.json +14 -0
  106. package/mcp-builtin/presets/gitee/package-lock.json +105 -0
  107. package/mcp-builtin/presets/gitee/package.json +10 -0
  108. package/mcp-builtin/presets/notion/package-lock.json +2243 -0
  109. package/mcp-builtin/presets/notion/package.json +10 -0
  110. package/mcp-builtin/presets/sentry/package-lock.json +28 -0
  111. package/mcp-builtin/presets/sentry/package.json +10 -0
  112. package/package.json +75 -5
  113. package/web/dist/THIRD-PARTY-NOTICES.txt +1944 -0
  114. package/web/dist/assets/index-B9oWPSod.css +1 -0
  115. package/web/dist/assets/index-C5qBMzFX.js +68 -0
  116. package/web/dist/icons/app-icon.png +0 -0
  117. package/web/dist/icons/apple-touch-icon.png +0 -0
  118. package/web/dist/icons/favicon-16.png +0 -0
  119. package/web/dist/icons/favicon-32.png +0 -0
  120. package/web/dist/icons/favicon-64.png +0 -0
  121. package/web/dist/icons/tenon-mark.svg +1 -0
  122. package/web/dist/icons/yew-mark.svg +1 -0
  123. package/web/dist/index.html +18 -0
  124. package/web/dist/mascot/gift.webp +0 -0
  125. package/web/dist/mascot/greeting.webp +0 -0
  126. package/web/dist/mascot/happy.webp +0 -0
  127. package/web/dist/mascot/lost.webp +0 -0
  128. package/web/dist/mascot/shush.webp +0 -0
  129. package/web/dist/mascot/sleepy.webp +0 -0
  130. package/web/dist/mascot/sorry.webp +0 -0
  131. package/web/dist/mascot/thinking.webp +0 -0
  132. package/web/dist/mascot/waking.webp +0 -0
  133. package/web/dist/mascot/writing.webp +0 -0
@@ -0,0 +1,152 @@
1
+ import { permissionModeOf } from "../../shared/types.js";
2
+ /** Attribute values stay on one line and cannot close the tag they sit in. */
3
+ const attr = (value) => value.replace(/["\n\r<>]/g, " ");
4
+ /**
5
+ * Text written by a session or a script cannot open or close Yew's own tags: `<letter`, `</letter`,
6
+ * `<decision` and `</decision` are written with `&lt;`, so a letter cannot carry a fake decision of the
7
+ * person. Only what the model reads changes; the interface shows the text as written.
8
+ */
9
+ export function neutralize(text) {
10
+ return text.replace(/<(\/?)(letter|decision)\b/gi, "&lt;$1$2");
11
+ }
12
+ function senderLabel(letter) {
13
+ if (letter.fromKind === "cli")
14
+ return "the command line (yew send)";
15
+ if (letter.fromKind === "person")
16
+ return "the person";
17
+ if (letter.fromKind === "yew")
18
+ return `the scheduled task '${letter.fromName}' (set up by the person)`;
19
+ return letter.fromName;
20
+ }
21
+ /** The decision as Yew recorded it, for a session to rely on. */
22
+ export function decisionRef(card) {
23
+ return {
24
+ number: card.number,
25
+ title: card.title,
26
+ choice: card.choice === null ? null : (card.options[card.choice]?.label ?? null),
27
+ note: card.note,
28
+ decidedAt: card.decidedAt ?? card.updatedAt,
29
+ };
30
+ }
31
+ /** What the interface shows for a delivered letter. */
32
+ export function letterRef(letter, decision, schedule = null) {
33
+ return {
34
+ id: letter.id,
35
+ kind: letter.kind,
36
+ from: { kind: letter.fromKind, sessionId: letter.fromSession, name: letter.fromName },
37
+ summary: letter.summary,
38
+ body: letter.body,
39
+ ...(letter.auto ? { auto: true } : {}),
40
+ ...(decision ? { decision } : {}),
41
+ ...(schedule ? { schedule } : {}),
42
+ };
43
+ }
44
+ function decisionLines(decision) {
45
+ return [
46
+ `Question: ${neutralize(decision.title)}`,
47
+ decision.choice
48
+ ? `Chosen: ${neutralize(decision.choice)}`
49
+ : "No option was chosen; the note is the answer.",
50
+ ...(decision.note ? [`Note: ${neutralize(decision.note)}`] : []),
51
+ ];
52
+ }
53
+ /**
54
+ * What the model reads for a delivered letter. The closing tag repeats the letter's id, which the sender
55
+ * could not know while writing, so text inside a letter cannot pass itself off as the end of it. `note`
56
+ * is Yew's own line about the letter, such as how a scheduled run works.
57
+ */
58
+ export function letterText(letter, decision, schedule = null, note = null) {
59
+ if (letter.fromKind === "person" && decision) {
60
+ return [
61
+ `<decision number="${decision.number}" from="the person" recorded-by="Yew">`,
62
+ ...decisionLines(decision),
63
+ `</decision number="${decision.number}">`,
64
+ ].join("\n");
65
+ }
66
+ const attributes = [
67
+ `id="${letter.id}"`,
68
+ `kind="${letter.kind}"`,
69
+ `from="${attr(senderLabel(letter))}"`,
70
+ ...(letter.fromSession ? [`from-id="${letter.fromSession}"`] : []),
71
+ `thread="${letter.threadId}"`,
72
+ ...(letter.replyTo ? [`reply-to="${letter.replyTo}"`] : []),
73
+ ...(letter.auto ? ['auto="true"'] : []),
74
+ ...(schedule && letter.fromKind !== "yew" ? [`schedule="${attr(schedule.name)}"`] : []),
75
+ ];
76
+ const lines = [`<letter ${attributes.join(" ")}>`, neutralize(letter.summary)];
77
+ if (letter.body)
78
+ lines.push("", neutralize(letter.body));
79
+ if (decision) {
80
+ lines.push("", `[Yew checked decision #${decision.number}: the person decided it in Yew.]`, ...decisionLines(decision));
81
+ }
82
+ if (note)
83
+ lines.push("", `[Yew] ${note}`);
84
+ lines.push(`</letter id="${letter.id}">`);
85
+ return lines.join("\n");
86
+ }
87
+ /** A decision for check_decision, with its state told plainly. */
88
+ export function decisionReport(card, names) {
89
+ const lines = [];
90
+ if (card.status === "pending")
91
+ lines.push(`#${card.number} is still waiting for the person.`);
92
+ else if (card.status === "withdrawn")
93
+ lines.push(`#${card.number} was withdrawn: ${neutralize(card.withdrawnReason ?? "")}`);
94
+ else {
95
+ const when = new Date(card.decidedAt ?? card.updatedAt).toISOString();
96
+ lines.push(`#${card.number} was decided by the person in Yew (${when}).`);
97
+ }
98
+ lines.push(`Question: ${neutralize(card.title)}`);
99
+ if (card.options.length > 0) {
100
+ lines.push(`Options: ${card.options
101
+ .map((option, index) => `${index + 1}. ${neutralize(option.label)}${index === card.recommended ? " (recommended)" : ""}`)
102
+ .join("; ")}`);
103
+ }
104
+ if (card.undoable !== null) {
105
+ const how = card.reversible ? ` (${neutralize(card.reversible)})` : "";
106
+ lines.push(`Can be undone: ${card.undoable ? "yes" : "no"}${how}`);
107
+ }
108
+ if (card.status === "decided") {
109
+ const chosen = card.choice === null ? null : card.options[card.choice]?.label;
110
+ lines.push(chosen ? `Chosen: ${neutralize(chosen)}` : "No option was chosen; the note is the answer.");
111
+ if (card.note)
112
+ lines.push(`Note: ${neutralize(card.note)}`);
113
+ }
114
+ const requester = card.requestedBy ? names(card.requestedBy) : null;
115
+ if (requester)
116
+ lines.push(`Requested by: ${requester}`);
117
+ return lines.join("\n");
118
+ }
119
+ /** One line per session for list_sessions. */
120
+ export function directoryLine(session, marks) {
121
+ const kind = `${session.kind} ${session.cwd ? `code (${session.cwd})` : "chat"}`;
122
+ const parts = [session.id, session.name, kind, session.status];
123
+ if (marks.group)
124
+ parts.push(`group: ${marks.group}`);
125
+ parts.push(`model: ${session.provider}/${session.model}`);
126
+ parts.push(`permission: ${permissionModeOf(session.options)}`);
127
+ const options = session.options;
128
+ if (options.receive && options.receive !== "accept")
129
+ parts.push(`receives: ${options.receive}`);
130
+ if (options.letterQuota)
131
+ parts.push(`letter quota: ${options.letterQuota}`);
132
+ if (options.dailyBudget)
133
+ parts.push(`daily budget: $${options.dailyBudget}`);
134
+ if (options.canPostCards)
135
+ parts.push("can post cards");
136
+ if (options.canOrganize)
137
+ parts.push("can manage Yew");
138
+ if (session.pinned)
139
+ parts.push("pinned");
140
+ if (marks.main)
141
+ parts.push("the main conversation");
142
+ if (marks.you)
143
+ parts.push("you");
144
+ if (marks.parentName)
145
+ parts.push(`opened by ${marks.parentName}`);
146
+ if (session.outcome)
147
+ parts.push(`result: ${session.outcome}`);
148
+ const role = session.responsibility.trim().split("\n")[0]?.trim();
149
+ if (role)
150
+ parts.push(`role: ${role.length > 120 ? `${role.slice(0, 120)}…` : role}`);
151
+ return `- ${parts.join(" · ")}`;
152
+ }