@lelouchhe/webagent 0.9.0 → 0.10.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 (47) hide show
  1. package/README.md +39 -14
  2. package/config.toml +7 -27
  3. package/dist/index.html +4 -4
  4. package/dist/js/app.INIQQEGD.js +5 -0
  5. package/dist/js/{chunk.S5LRNRJI.js → chunk.7WADDFJZ.js} +27 -27
  6. package/dist/js/viewer.RHZMFYWJ.js +1 -0
  7. package/dist/login.html +1 -1
  8. package/dist/share-viewer.html +5 -5
  9. package/dist/{styles.00nlhhf3.css → styles.01aj0l37.css} +19 -2
  10. package/dist/sw.js +6 -6
  11. package/lib/attachment-dispatch.js +60 -31
  12. package/lib/attachment-interceptor.js +7 -7
  13. package/lib/attachment-labels.js +1 -1
  14. package/lib/attachments.js +25 -0
  15. package/lib/auth-middleware.js +2 -2
  16. package/lib/auth.js +2 -2
  17. package/lib/bridge.js +109 -83
  18. package/lib/client-registry.js +12 -12
  19. package/lib/config.js +2 -31
  20. package/lib/event-handler.js +143 -90
  21. package/lib/files/routes.js +1 -1
  22. package/lib/mcp/capability.js +74 -0
  23. package/lib/mcp/server.js +148 -0
  24. package/lib/mcp/task-history.js +245 -0
  25. package/lib/mcp/task-host.js +253 -0
  26. package/lib/mcp/tools.js +168 -0
  27. package/lib/mode-bucket.js +1 -1
  28. package/lib/push-service.js +33 -35
  29. package/lib/routes.js +947 -489
  30. package/lib/server.js +64 -16
  31. package/lib/share/routes.js +88 -88
  32. package/lib/shared/task-reference.js +20 -0
  33. package/lib/sse-manager.js +8 -8
  34. package/lib/store.js +941 -314
  35. package/lib/task-collaboration.js +15 -0
  36. package/lib/task-manager.js +1409 -0
  37. package/lib/task-path.js +131 -0
  38. package/lib/{session-state.js → task-state.js} +64 -41
  39. package/lib/task-tree-lock.js +74 -0
  40. package/lib/{sessions-anchor.js → tasks-anchor.js} +8 -7
  41. package/lib/tokens.js +1 -1
  42. package/lib/types.js +2 -2
  43. package/package.json +7 -1
  44. package/dist/js/app.QC7IRDTP.js +0 -5
  45. package/dist/js/viewer.GP5VXAUY.js +0 -1
  46. package/lib/session-manager.js +0 -638
  47. package/lib/title-service.js +0 -95
@@ -1,95 +0,0 @@
1
- import { log } from "./log.js";
2
- import { pickModelByPatterns } from "./model-picker.js";
3
- const tlog = log.scope("title");
4
- export class TitleService {
5
- titleSessionId = null;
6
- activeSourceSessions = new Set();
7
- cancelledSourceSessions = new Set();
8
- defaultCwd;
9
- modelPatterns;
10
- store;
11
- sessions;
12
- constructor(store, sessions, defaultCwd, modelPatterns = []) {
13
- this.store = store;
14
- this.sessions = sessions;
15
- this.defaultCwd = defaultCwd;
16
- this.modelPatterns = modelPatterns;
17
- }
18
- /** Generate a title for the session (non-blocking, fire-and-forget). */
19
- generate(bridge, userMessage, sessionId, onTitle) {
20
- if (this.sessions.sessionHasTitle.has(sessionId) ||
21
- this.activeSourceSessions.has(sessionId))
22
- return;
23
- this._generate(bridge, userMessage, sessionId)
24
- .then((title) => {
25
- if (title && onTitle)
26
- onTitle(title);
27
- })
28
- .catch((err) => {
29
- tlog.error("generation failed", { error: err });
30
- });
31
- }
32
- async _generate(bridge, userMessage, sessionId) {
33
- this.activeSourceSessions.add(sessionId);
34
- const tsId = await this.ensureTitleSession(bridge);
35
- if (!tsId) {
36
- this.activeSourceSessions.delete(sessionId);
37
- this.cancelledSourceSessions.delete(sessionId);
38
- return;
39
- }
40
- try {
41
- const prompt = `Generate a short title (max 30 chars, no quotes) for a chat that starts with this message. Reply with ONLY the title, nothing else:\n\n${userMessage.slice(0, 500)}`;
42
- const title = await bridge.promptForText(tsId, prompt);
43
- if (!title || this.cancelledSourceSessions.has(sessionId))
44
- return;
45
- // User may have set a title while generation was in flight
46
- if (this.sessions.sessionHasTitle.has(sessionId))
47
- return;
48
- const cleaned = title
49
- .replace(/^["']|["']$/g, "")
50
- .trim()
51
- .slice(0, 30);
52
- if (!cleaned)
53
- return;
54
- this.store.updateSessionTitle(sessionId, cleaned);
55
- this.sessions.sessionHasTitle.add(sessionId);
56
- return cleaned;
57
- }
58
- finally {
59
- this.activeSourceSessions.delete(sessionId);
60
- this.cancelledSourceSessions.delete(sessionId);
61
- }
62
- }
63
- async cancel(sessionId, bridge) {
64
- this.cancelledSourceSessions.add(sessionId);
65
- if (!this.titleSessionId || !this.activeSourceSessions.has(sessionId))
66
- return;
67
- await bridge.cancelAgentSession(this.titleSessionId);
68
- }
69
- /** Clear the cached title session ID (e.g. after agent reload). */
70
- invalidate() {
71
- this.titleSessionId = null;
72
- }
73
- /** Ensure the dedicated title session exists. Returns session ID or null. */
74
- async ensureTitleSession(bridge) {
75
- if (this.titleSessionId)
76
- return this.titleSessionId;
77
- try {
78
- const { sessionId: id, configOptions } = await bridge.newSession(this.defaultCwd, { silent: true });
79
- this.store.registerInternalAgentSession(id);
80
- // Pick the cheapest available model by matching id substrings against
81
- // the agent's reported availableModels (`configOptions[id=model].options`).
82
- // Empty pattern list, no model option, or no match → skip the call and
83
- // inherit the agent's default model (`currentModelId`).
84
- const picked = pickModelByPatterns(configOptions, this.modelPatterns);
85
- if (picked) {
86
- await bridge.setAgentConfigOption(id, "model", picked).catch(() => []);
87
- }
88
- this.titleSessionId = id;
89
- return id;
90
- }
91
- catch {
92
- return null;
93
- }
94
- }
95
- }