@clawos-dev/clawd 0.2.7 → 0.2.8-beta.2.525faa1

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 (2) hide show
  1. package/dist/cli.cjs +348 -239
  2. package/package.json +1 -1
package/dist/cli.cjs CHANGED
@@ -8075,7 +8075,6 @@ Env (advanced):
8075
8075
  `;
8076
8076
 
8077
8077
  // src/index.ts
8078
- var import_node_os10 = __toESM(require("os"), 1);
8079
8078
  var import_node_path15 = __toESM(require("path"), 1);
8080
8079
  var import_node_fs16 = __toESM(require("fs"), 1);
8081
8080
 
@@ -17135,6 +17134,244 @@ function writeAuthFile(file, content) {
17135
17134
  }
17136
17135
  }
17137
17136
 
17137
+ // src/handlers/session.ts
17138
+ function buildSessionHandlers(deps) {
17139
+ const { manager, observer, getAdapter: getAdapter2 } = deps;
17140
+ const create = async (frame) => {
17141
+ const args = SessionCreateArgs.parse(frame);
17142
+ const { response, broadcast } = manager.create(args);
17143
+ return { response: { type: "session:info", ...response }, broadcast };
17144
+ };
17145
+ const list = async () => {
17146
+ const { response } = manager.list();
17147
+ return { response: { type: "session:list", ...response } };
17148
+ };
17149
+ const get = async (frame) => {
17150
+ const args = SessionIdArgs.parse(frame);
17151
+ const { response } = manager.get(args);
17152
+ return { response: { type: "session:info", ...response } };
17153
+ };
17154
+ const update = async (frame) => {
17155
+ const args = SessionUpdateArgs.parse(frame);
17156
+ const { response, broadcast } = manager.update(args);
17157
+ return { response: { type: "session:info", ...response }, broadcast };
17158
+ };
17159
+ const del = async (frame) => {
17160
+ const args = SessionIdArgs.parse(frame);
17161
+ const { broadcast } = manager.delete(args);
17162
+ return {
17163
+ response: { type: "session:deleted", sessionId: args.sessionId },
17164
+ broadcast
17165
+ };
17166
+ };
17167
+ const send = async (frame) => {
17168
+ const args = SessionSendArgs.parse(frame);
17169
+ const { broadcast } = manager.send(args);
17170
+ return { response: { type: "session:send", ok: true }, broadcast };
17171
+ };
17172
+ const stop = async (frame) => {
17173
+ const args = SessionIdArgs.parse(frame);
17174
+ const { broadcast } = manager.stop(args);
17175
+ return { response: { type: "session:stop", ok: true }, broadcast };
17176
+ };
17177
+ const interrupt = async (frame) => {
17178
+ const args = SessionIdArgs.parse(frame);
17179
+ const { broadcast } = await manager.interrupt(args);
17180
+ return { response: { type: "session:interrupt", ok: true }, broadcast };
17181
+ };
17182
+ const rewind = async (frame) => {
17183
+ const args = SessionRewindArgs.parse(frame);
17184
+ const { response, broadcast } = await manager.rewind(args);
17185
+ return { response: { type: "session:rewind", ...response }, broadcast };
17186
+ };
17187
+ const rewindDiff = async (frame) => {
17188
+ const args = SessionRewindDiffArgs.parse(frame);
17189
+ const { response } = await manager.rewindDiff(args);
17190
+ return { response: { type: "session:rewind-diff", ...response } };
17191
+ };
17192
+ const rewindableMessageIds = async (frame) => {
17193
+ const args = SessionRewindableMessageIdsArgs.parse(frame);
17194
+ const { response } = manager.rewindableMessageIds(args);
17195
+ return {
17196
+ response: { type: "session:rewindable-message-ids", ...response }
17197
+ };
17198
+ };
17199
+ const newSession = async (frame) => {
17200
+ const args = SessionIdArgs.parse(frame);
17201
+ observer.stop(args.sessionId);
17202
+ const { response, broadcast } = manager.newSession(args);
17203
+ return { response: { type: "session:info", ...response }, broadcast };
17204
+ };
17205
+ const resume = async (frame) => {
17206
+ const args = SessionResumeArgs.parse(frame);
17207
+ const { response, broadcast } = manager.resume(args);
17208
+ return { response: { type: "session:info", ...response }, broadcast };
17209
+ };
17210
+ const observe = async (frame) => {
17211
+ const args = SessionObserveArgs.parse(frame);
17212
+ const { response: file } = manager.get({ sessionId: args.sessionId });
17213
+ const sessionFile = file;
17214
+ manager.ensureSession(sessionFile);
17215
+ const adapter = getAdapter2(sessionFile.tool ?? "claude");
17216
+ observer.start({
17217
+ sessionId: args.sessionId,
17218
+ cwd: sessionFile.cwd,
17219
+ toolSessionId: args.toolSessionId,
17220
+ jsonlPath: args.jsonlPath,
17221
+ adapter
17222
+ });
17223
+ return { response: { type: "session:observe", ok: true } };
17224
+ };
17225
+ const events = async (frame) => {
17226
+ const args = SessionEventsArgs.parse(frame);
17227
+ const { response } = manager.getEvents(args);
17228
+ return { response: { type: "session:events", ...response } };
17229
+ };
17230
+ const subscribe = async (frame, client) => {
17231
+ if (typeof frame.sessionId === "string")
17232
+ addSubscription(client, frame.sessionId);
17233
+ return {
17234
+ response: { type: "subscribed", sessionId: frame.sessionId }
17235
+ };
17236
+ };
17237
+ const unsubscribe = async (frame, client) => {
17238
+ if (typeof frame.sessionId === "string")
17239
+ removeSubscription(client, frame.sessionId);
17240
+ return {
17241
+ response: { type: "unsubscribed", sessionId: frame.sessionId }
17242
+ };
17243
+ };
17244
+ const pin = async (frame) => {
17245
+ const args = SessionPinArgs.parse(frame);
17246
+ const { response, broadcast } = manager.pin(args);
17247
+ return { response: { type: "session:info", ...response }, broadcast };
17248
+ };
17249
+ return {
17250
+ "session:create": create,
17251
+ "session:list": list,
17252
+ "session:get": get,
17253
+ "session:update": update,
17254
+ "session:delete": del,
17255
+ "session:send": send,
17256
+ "session:stop": stop,
17257
+ "session:interrupt": interrupt,
17258
+ "session:rewind": rewind,
17259
+ "session:rewind-diff": rewindDiff,
17260
+ "session:rewindable-message-ids": rewindableMessageIds,
17261
+ "session:new": newSession,
17262
+ "session:resume": resume,
17263
+ "session:observe": observe,
17264
+ "session:events": events,
17265
+ "session:subscribe": subscribe,
17266
+ "session:unsubscribe": unsubscribe,
17267
+ "session:pin": pin
17268
+ };
17269
+ }
17270
+
17271
+ // src/handlers/permission.ts
17272
+ function buildPermissionHandlers(deps) {
17273
+ const { manager } = deps;
17274
+ const respond = async (frame) => {
17275
+ const args = PermissionRespondArgs.parse(frame);
17276
+ const { broadcast } = manager.respondPermission(args);
17277
+ return { response: { type: "permission:respond", ok: true }, broadcast };
17278
+ };
17279
+ return {
17280
+ "permission:respond": respond
17281
+ };
17282
+ }
17283
+
17284
+ // src/workspace/recent-dirs.ts
17285
+ function listRecentDirs(store, limit = 50) {
17286
+ const sessions = store.list();
17287
+ const latestByCwd = /* @__PURE__ */ new Map();
17288
+ for (const s of sessions) {
17289
+ if (!s.cwd) continue;
17290
+ const prev = latestByCwd.get(s.cwd);
17291
+ if (!prev || s.updatedAt > prev) {
17292
+ latestByCwd.set(s.cwd, s.updatedAt);
17293
+ }
17294
+ }
17295
+ return Array.from(latestByCwd.entries()).map(([cwd, updatedAt]) => ({ cwd, updatedAt })).sort((a, b) => a.updatedAt > b.updatedAt ? -1 : a.updatedAt < b.updatedAt ? 1 : 0).slice(0, limit);
17296
+ }
17297
+
17298
+ // src/handlers/history.ts
17299
+ function buildHistoryHandlers(deps) {
17300
+ const { manager, history, store } = deps;
17301
+ const projects = async () => {
17302
+ const list2 = await history.listProjects();
17303
+ return { response: { type: "history:projects", projects: list2 } };
17304
+ };
17305
+ const list = async (frame) => {
17306
+ const args = HistoryListArgs.parse(frame);
17307
+ const sessions = await history.listSessions(args);
17308
+ return { response: { type: "history:list", sessions } };
17309
+ };
17310
+ const read = async (frame) => {
17311
+ const args = HistoryReadArgs.parse(frame);
17312
+ const { response: file } = manager.get({ sessionId: args.sessionId });
17313
+ if (!file.toolSessionId) {
17314
+ return {
17315
+ response: { type: "history:read", messages: [], total: 0, offset: 0 }
17316
+ };
17317
+ }
17318
+ const res = await history.read({
17319
+ cwd: file.cwd,
17320
+ toolSessionId: file.toolSessionId,
17321
+ limit: args.limit,
17322
+ offset: args.offset
17323
+ });
17324
+ return { response: { type: "history:read", ...res } };
17325
+ };
17326
+ const subagents = async (frame) => {
17327
+ const args = HistorySubagentsArgs.parse(frame);
17328
+ const subs = await history.listSubagents(args);
17329
+ return { response: { type: "history:subagents", subagents: subs } };
17330
+ };
17331
+ const subagentRead = async (frame) => {
17332
+ const args = HistorySubagentReadArgs.parse(frame);
17333
+ const res = await history.readSubagent(args);
17334
+ return { response: { type: "history:subagent-read", ...res } };
17335
+ };
17336
+ const recentDirs = async () => {
17337
+ const dirs = listRecentDirs(store);
17338
+ return { response: { type: "history:recentDirs", dirs } };
17339
+ };
17340
+ return {
17341
+ "history:projects": projects,
17342
+ "history:list": list,
17343
+ "history:read": read,
17344
+ "history:subagents": subagents,
17345
+ "history:subagent-read": subagentRead,
17346
+ "history:recentDirs": recentDirs
17347
+ };
17348
+ }
17349
+
17350
+ // src/handlers/workspace.ts
17351
+ function buildWorkspaceHandlers(deps) {
17352
+ const { workspace, skills } = deps;
17353
+ const list = async (frame) => {
17354
+ const args = WorkspaceListArgs.parse(frame);
17355
+ const res = workspace.list(args);
17356
+ return { response: { type: "workspace:list", ...res } };
17357
+ };
17358
+ const read = async (frame) => {
17359
+ const args = WorkspaceReadArgs.parse(frame);
17360
+ const res = workspace.read(args);
17361
+ return { response: { type: "workspace:read", ...res } };
17362
+ };
17363
+ const skillsList = async (frame) => {
17364
+ const args = SkillsListArgs.parse(frame);
17365
+ const list2 = skills.list(args);
17366
+ return { response: { type: "skills:list", skills: list2 } };
17367
+ };
17368
+ return {
17369
+ "workspace:list": list,
17370
+ "workspace:read": read,
17371
+ "skills:list": skillsList
17372
+ };
17373
+ }
17374
+
17138
17375
  // src/workspace/git.ts
17139
17376
  var import_node_child_process5 = require("child_process");
17140
17377
  var import_node_fs15 = __toESM(require("fs"), 1);
@@ -17371,23 +17608,122 @@ async function removeWorktree(input) {
17371
17608
  }
17372
17609
  }
17373
17610
 
17374
- // src/workspace/recent-dirs.ts
17375
- function listRecentDirs(store, limit = 50) {
17376
- const sessions = store.list();
17377
- const latestByCwd = /* @__PURE__ */ new Map();
17378
- for (const s of sessions) {
17379
- if (!s.cwd) continue;
17380
- const prev = latestByCwd.get(s.cwd);
17381
- if (!prev || s.updatedAt > prev) {
17382
- latestByCwd.set(s.cwd, s.updatedAt);
17611
+ // src/handlers/git.ts
17612
+ function buildGitHandlers() {
17613
+ const root = async (frame) => {
17614
+ const args = GitRootArgs.parse(frame);
17615
+ const res = await getGitRoot(args.cwd);
17616
+ return { response: { type: "git:root", ...res } };
17617
+ };
17618
+ const branch = async (frame) => {
17619
+ const args = GitBranchArgs.parse(frame);
17620
+ const res = await readGitBranch(args.cwd);
17621
+ return { response: { type: "git:branch", ...res } };
17622
+ };
17623
+ const branches = async (frame) => {
17624
+ const args = GitBranchesArgs.parse(frame);
17625
+ const res = await listGitBranches(args.cwd);
17626
+ return { response: { type: "git:branches", ...res } };
17627
+ };
17628
+ const worktreePrefix = async () => {
17629
+ return {
17630
+ response: { type: "git:worktree:prefix", prefix: computePrefix() }
17631
+ };
17632
+ };
17633
+ const worktreeCreate = async (frame) => {
17634
+ const args = GitWorktreeCreateArgs.parse(frame);
17635
+ try {
17636
+ const res = await createWorktree(args);
17637
+ return { response: { type: "git:worktree:create", ...res } };
17638
+ } catch (err) {
17639
+ throw new ClawdError(ERROR_CODES.INTERNAL, err.message);
17383
17640
  }
17384
- }
17385
- return Array.from(latestByCwd.entries()).map(([cwd, updatedAt]) => ({ cwd, updatedAt })).sort((a, b) => a.updatedAt > b.updatedAt ? -1 : a.updatedAt < b.updatedAt ? 1 : 0).slice(0, limit);
17641
+ };
17642
+ const worktreeRemove = async (frame) => {
17643
+ const args = GitWorktreeRemoveArgs.parse(frame);
17644
+ try {
17645
+ await removeWorktree(args);
17646
+ return { response: { type: "git:worktree:remove", ok: true } };
17647
+ } catch (err) {
17648
+ throw new ClawdError(ERROR_CODES.INTERNAL, err.message);
17649
+ }
17650
+ };
17651
+ return {
17652
+ "git:root": root,
17653
+ "git:branch": branch,
17654
+ "git:branches": branches,
17655
+ "git:worktree:prefix": worktreePrefix,
17656
+ "git:worktree:create": worktreeCreate,
17657
+ "git:worktree:remove": worktreeRemove
17658
+ };
17659
+ }
17660
+
17661
+ // src/handlers/capabilities.ts
17662
+ function buildCapabilitiesHandlers(deps) {
17663
+ const { manager } = deps;
17664
+ const get = async (frame) => {
17665
+ const args = CapabilitiesGetArgs.parse(frame);
17666
+ const caps = await manager.getCapabilities(args.tool);
17667
+ return { response: { type: "capabilities:get", ...caps } };
17668
+ };
17669
+ return {
17670
+ "capabilities:get": get
17671
+ };
17386
17672
  }
17387
17673
 
17674
+ // src/handlers/meta.ts
17675
+ var import_node_os10 = __toESM(require("os"), 1);
17676
+
17388
17677
  // src/version.ts
17389
17678
  var version = "0.2.6".length > 0 ? "0.2.6" : "dev";
17390
17679
 
17680
+ // src/handlers/meta.ts
17681
+ function buildReadyFrame(deps) {
17682
+ const info = deps.manager.info();
17683
+ const tools = [];
17684
+ for (const id of listRegistered()) {
17685
+ try {
17686
+ const a = deps.getAdapter(id);
17687
+ tools.push({ id: a.id, available: true });
17688
+ } catch {
17689
+ tools.push({ id, available: false });
17690
+ }
17691
+ }
17692
+ return {
17693
+ version,
17694
+ protocolVersion: PROTOCOL_VERSION,
17695
+ hostname: import_node_os10.default.hostname(),
17696
+ os: process.platform,
17697
+ tools,
17698
+ runningSessions: info.runningSessions
17699
+ };
17700
+ }
17701
+ function buildMetaHandlers(deps) {
17702
+ const info = async () => ({
17703
+ response: { type: "info", ...buildReadyFrame(deps) }
17704
+ });
17705
+ const ping = async () => ({
17706
+ response: { type: "pong", at: Date.now() }
17707
+ });
17708
+ return {
17709
+ info,
17710
+ ping
17711
+ };
17712
+ }
17713
+
17714
+ // src/handlers/index.ts
17715
+ function buildMethodHandlers(deps) {
17716
+ return {
17717
+ ...buildSessionHandlers(deps),
17718
+ ...buildPermissionHandlers(deps),
17719
+ ...buildHistoryHandlers(deps),
17720
+ ...buildWorkspaceHandlers(deps),
17721
+ ...buildGitHandlers(),
17722
+ ...buildCapabilitiesHandlers(deps),
17723
+ ...buildMetaHandlers(deps)
17724
+ };
17725
+ }
17726
+
17391
17727
  // src/index.ts
17392
17728
  async function startDaemon(config) {
17393
17729
  const logger = createLogger({
@@ -17574,233 +17910,6 @@ ${bar}
17574
17910
  authToken: resolvedAuthToken
17575
17911
  };
17576
17912
  }
17577
- function buildMethodHandlers(deps) {
17578
- const { manager, workspace, skills, history, observer, getAdapter: getAdapter2, store } = deps;
17579
- return {
17580
- "session:create": async (frame) => {
17581
- const args = SessionCreateArgs.parse(frame);
17582
- const { response, broadcast } = manager.create(args);
17583
- return { response: { type: "session:info", ...response }, broadcast };
17584
- },
17585
- "session:list": async () => {
17586
- const { response } = manager.list();
17587
- return { response: { type: "session:list", ...response } };
17588
- },
17589
- "session:get": async (frame) => {
17590
- const args = SessionIdArgs.parse(frame);
17591
- const { response } = manager.get(args);
17592
- return { response: { type: "session:info", ...response } };
17593
- },
17594
- "session:update": async (frame) => {
17595
- const args = SessionUpdateArgs.parse(frame);
17596
- const { response, broadcast } = manager.update(args);
17597
- return { response: { type: "session:info", ...response }, broadcast };
17598
- },
17599
- "session:delete": async (frame) => {
17600
- const args = SessionIdArgs.parse(frame);
17601
- const { broadcast } = manager.delete(args);
17602
- return { response: { type: "session:deleted", sessionId: args.sessionId }, broadcast };
17603
- },
17604
- "session:send": async (frame) => {
17605
- const args = SessionSendArgs.parse(frame);
17606
- const { broadcast } = manager.send(args);
17607
- return { response: { type: "session:send", ok: true }, broadcast };
17608
- },
17609
- "session:stop": async (frame) => {
17610
- const args = SessionIdArgs.parse(frame);
17611
- const { broadcast } = manager.stop(args);
17612
- return { response: { type: "session:stop", ok: true }, broadcast };
17613
- },
17614
- "session:interrupt": async (frame) => {
17615
- const args = SessionIdArgs.parse(frame);
17616
- const { broadcast } = await manager.interrupt(args);
17617
- return { response: { type: "session:interrupt", ok: true }, broadcast };
17618
- },
17619
- "session:rewind": async (frame) => {
17620
- const args = SessionRewindArgs.parse(frame);
17621
- const { response, broadcast } = await manager.rewind(args);
17622
- return { response: { type: "session:rewind", ...response }, broadcast };
17623
- },
17624
- "session:rewind-diff": async (frame) => {
17625
- const args = SessionRewindDiffArgs.parse(frame);
17626
- const { response } = await manager.rewindDiff(args);
17627
- return { response: { type: "session:rewind-diff", ...response } };
17628
- },
17629
- "session:rewindable-message-ids": async (frame) => {
17630
- const args = SessionRewindableMessageIdsArgs.parse(frame);
17631
- const { response } = manager.rewindableMessageIds(args);
17632
- return { response: { type: "session:rewindable-message-ids", ...response } };
17633
- },
17634
- "session:new": async (frame) => {
17635
- const args = SessionIdArgs.parse(frame);
17636
- observer.stop(args.sessionId);
17637
- const { response, broadcast } = manager.newSession(args);
17638
- return { response: { type: "session:info", ...response }, broadcast };
17639
- },
17640
- "session:resume": async (frame) => {
17641
- const args = SessionResumeArgs.parse(frame);
17642
- const { response, broadcast } = manager.resume(args);
17643
- return { response: { type: "session:info", ...response }, broadcast };
17644
- },
17645
- "session:observe": async (frame) => {
17646
- const args = SessionObserveArgs.parse(frame);
17647
- const { response: file } = manager.get({ sessionId: args.sessionId });
17648
- const sessionFile = file;
17649
- manager.ensureSession(sessionFile);
17650
- const adapter = getAdapter2(sessionFile.tool ?? "claude");
17651
- observer.start({
17652
- sessionId: args.sessionId,
17653
- cwd: sessionFile.cwd,
17654
- toolSessionId: args.toolSessionId,
17655
- jsonlPath: args.jsonlPath,
17656
- adapter
17657
- });
17658
- return { response: { type: "session:observe", ok: true } };
17659
- },
17660
- "session:events": async (frame) => {
17661
- const args = SessionEventsArgs.parse(frame);
17662
- const { response } = manager.getEvents(args);
17663
- return { response: { type: "session:events", ...response } };
17664
- },
17665
- "session:subscribe": async (frame, client) => {
17666
- if (typeof frame.sessionId === "string") addSubscription(client, frame.sessionId);
17667
- return { response: { type: "subscribed", sessionId: frame.sessionId } };
17668
- },
17669
- "session:unsubscribe": async (frame, client) => {
17670
- if (typeof frame.sessionId === "string") removeSubscription(client, frame.sessionId);
17671
- return { response: { type: "unsubscribed", sessionId: frame.sessionId } };
17672
- },
17673
- "session:pin": async (frame) => {
17674
- const args = SessionPinArgs.parse(frame);
17675
- const { response, broadcast } = manager.pin(args);
17676
- return { response: { type: "session:info", ...response }, broadcast };
17677
- },
17678
- "permission:respond": async (frame) => {
17679
- const args = PermissionRespondArgs.parse(frame);
17680
- const { broadcast } = manager.respondPermission(args);
17681
- return { response: { type: "permission:respond", ok: true }, broadcast };
17682
- },
17683
- "history:projects": async () => {
17684
- const projects = await history.listProjects();
17685
- return { response: { type: "history:projects", projects } };
17686
- },
17687
- "history:list": async (frame) => {
17688
- const args = HistoryListArgs.parse(frame);
17689
- const sessions = await history.listSessions(args);
17690
- return { response: { type: "history:list", sessions } };
17691
- },
17692
- "history:read": async (frame) => {
17693
- const args = HistoryReadArgs.parse(frame);
17694
- const { response: file } = manager.get({ sessionId: args.sessionId });
17695
- if (!file.toolSessionId) {
17696
- return {
17697
- response: { type: "history:read", messages: [], total: 0, offset: 0 }
17698
- };
17699
- }
17700
- const res = await history.read({
17701
- cwd: file.cwd,
17702
- toolSessionId: file.toolSessionId,
17703
- limit: args.limit,
17704
- offset: args.offset
17705
- });
17706
- return { response: { type: "history:read", ...res } };
17707
- },
17708
- "history:subagents": async (frame) => {
17709
- const args = HistorySubagentsArgs.parse(frame);
17710
- const subs = await history.listSubagents(args);
17711
- return { response: { type: "history:subagents", subagents: subs } };
17712
- },
17713
- "history:subagent-read": async (frame) => {
17714
- const args = HistorySubagentReadArgs.parse(frame);
17715
- const res = await history.readSubagent(args);
17716
- return { response: { type: "history:subagent-read", ...res } };
17717
- },
17718
- "history:recentDirs": async () => {
17719
- const dirs = listRecentDirs(store);
17720
- return { response: { type: "history:recentDirs", dirs } };
17721
- },
17722
- "workspace:list": async (frame) => {
17723
- const args = WorkspaceListArgs.parse(frame);
17724
- const res = workspace.list(args);
17725
- return { response: { type: "workspace:list", ...res } };
17726
- },
17727
- "workspace:read": async (frame) => {
17728
- const args = WorkspaceReadArgs.parse(frame);
17729
- const res = workspace.read(args);
17730
- return { response: { type: "workspace:read", ...res } };
17731
- },
17732
- "skills:list": async (frame) => {
17733
- const args = SkillsListArgs.parse(frame);
17734
- const list = skills.list(args);
17735
- return { response: { type: "skills:list", skills: list } };
17736
- },
17737
- "git:root": async (frame) => {
17738
- const args = GitRootArgs.parse(frame);
17739
- const res = await getGitRoot(args.cwd);
17740
- return { response: { type: "git:root", ...res } };
17741
- },
17742
- "git:branch": async (frame) => {
17743
- const args = GitBranchArgs.parse(frame);
17744
- const res = await readGitBranch(args.cwd);
17745
- return { response: { type: "git:branch", ...res } };
17746
- },
17747
- "git:branches": async (frame) => {
17748
- const args = GitBranchesArgs.parse(frame);
17749
- const res = await listGitBranches(args.cwd);
17750
- return { response: { type: "git:branches", ...res } };
17751
- },
17752
- "git:worktree:prefix": async () => {
17753
- return { response: { type: "git:worktree:prefix", prefix: computePrefix() } };
17754
- },
17755
- "git:worktree:create": async (frame) => {
17756
- const args = GitWorktreeCreateArgs.parse(frame);
17757
- try {
17758
- const res = await createWorktree(args);
17759
- return { response: { type: "git:worktree:create", ...res } };
17760
- } catch (err) {
17761
- throw new ClawdError(ERROR_CODES.INTERNAL, err.message);
17762
- }
17763
- },
17764
- "git:worktree:remove": async (frame) => {
17765
- const args = GitWorktreeRemoveArgs.parse(frame);
17766
- try {
17767
- await removeWorktree(args);
17768
- return { response: { type: "git:worktree:remove", ok: true } };
17769
- } catch (err) {
17770
- throw new ClawdError(ERROR_CODES.INTERNAL, err.message);
17771
- }
17772
- },
17773
- "capabilities:get": async (frame) => {
17774
- const args = CapabilitiesGetArgs.parse(frame);
17775
- const caps = await manager.getCapabilities(args.tool);
17776
- return { response: { type: "capabilities:get", ...caps } };
17777
- },
17778
- // 必须带 type:ext-clawd DaemonConnection.handleFrame 看到 frame.type 不是 string
17779
- // 直接丢弃整帧,pending requestId 永远不会被匹配,UI 端 info 调用就一直 pending 到超时。
17780
- info: async () => ({ response: { type: "info", ...buildReadyFrame(deps) } }),
17781
- ping: async () => ({ response: { type: "pong", at: Date.now() } })
17782
- };
17783
- }
17784
- function buildReadyFrame(deps) {
17785
- const info = deps.manager.info();
17786
- const tools = [];
17787
- for (const id of listRegistered()) {
17788
- try {
17789
- const a = deps.getAdapter(id);
17790
- tools.push({ id: a.id, available: true });
17791
- } catch {
17792
- tools.push({ id, available: false });
17793
- }
17794
- }
17795
- return {
17796
- version,
17797
- protocolVersion: PROTOCOL_VERSION,
17798
- hostname: import_node_os10.default.hostname(),
17799
- os: process.platform,
17800
- tools,
17801
- runningSessions: info.runningSessions
17802
- };
17803
- }
17804
17913
 
17805
17914
  // src/cli.ts
17806
17915
  async function main() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clawos-dev/clawd",
3
- "version": "0.2.7",
3
+ "version": "0.2.8-beta.2.525faa1",
4
4
  "description": "Standalone clawd daemon — Claude Code (and future Codex) session server over WebSocket",
5
5
  "type": "module",
6
6
  "license": "MIT",