@triflux/remote 10.0.0-alpha.1 → 10.0.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.
package/hub/index.mjs ADDED
@@ -0,0 +1,21 @@
1
+ // @triflux/remote — barrel export (auto-generated by pack.mjs)
2
+ // Server
3
+ export { startHub, getHubInfo, getOrCreateServer } from './server.mjs';
4
+
5
+ // Store
6
+ export { createStoreAdapter } from './store-adapter.mjs';
7
+
8
+ // Pipe
9
+ export { createPipeServer, getPipePath } from './pipe.mjs';
10
+
11
+ // Team
12
+ export { orchestrate, decomposeTask, buildLeadPrompt, buildPrompt } from './team/orchestrator.mjs';
13
+ export { createPsmuxSession, startCapture } from './team/psmux.mjs';
14
+ export { createConductor } from './team/conductor.mjs';
15
+
16
+ // Swarm
17
+ export { createSwarmLocks } from '../../../hub/team/swarm-locks.mjs';
18
+ export { parseShards, buildFileLeaseMap, buildMcpManifest, computeMergeOrder, planSwarm } from '../../../hub/team/swarm-planner.mjs';
19
+ export { createSwarmHypervisor, SWARM_STATES } from '../../../hub/team/swarm-hypervisor.mjs';
20
+ export { reconcile, buildRedundantIds, shouldRunRedundant } from '../../../hub/team/swarm-reconciler.mjs';
21
+ export { ensureWorktree, prepareIntegrationBranch, rebaseShardOntoIntegration, pruneWorktree } from '../../../hub/team/worktree-lifecycle.mjs';
package/hub/pipe.mjs CHANGED
@@ -4,23 +4,19 @@
4
4
  import net from 'node:net';
5
5
  import { existsSync, unlinkSync } from 'node:fs';
6
6
  import { randomUUID } from 'node:crypto';
7
- import {
8
- teamInfo,
9
- teamTaskList,
10
- teamTaskUpdate,
11
- teamSendMessage,
12
- } from './team-bridge.mjs';
13
- import { createPipeline } from './pipeline/index.mjs';
7
+ import { getTeamBridge } from '@triflux/core/hub/team-bridge.mjs';
8
+ import { createPipeline } from '@triflux/core/hub/pipeline/index.mjs';
14
9
  import {
15
10
  ensurePipelineTable,
16
11
  initPipelineState,
17
12
  listPipelineStates,
18
13
  readPipelineState,
19
- } from './pipeline/state.mjs';
20
- import { IS_WINDOWS, pipePath } from './platform.mjs';
14
+ } from '@triflux/core/hub/pipeline/state.mjs';
15
+ import { IS_WINDOWS, pipePath } from '@triflux/core/hub/platform.mjs';
21
16
  import { safeJsonParse } from './workers/worker-utils.mjs';
22
17
 
23
18
  const DEFAULT_HEARTBEAT_TTL_MS = 60000;
19
+ const TEAM_BRIDGE_NOT_REGISTERED = 'bridge_not_registered';
24
20
 
25
21
  /** 플랫폼별 pipe 경로 계산 */
26
22
  export function getPipePath(sessionId = process.pid) {
@@ -34,6 +30,87 @@ function normalizeTopics(topics) {
34
30
  .filter(Boolean);
35
31
  }
36
32
 
33
+ function getTeamBridgeMethod(methodName) {
34
+ const method = getTeamBridge()?.[methodName];
35
+ return typeof method === 'function' ? method : null;
36
+ }
37
+
38
+ function teamInfoFallback(payload = {}) {
39
+ return {
40
+ ok: true,
41
+ data: {
42
+ team: {
43
+ team_name: payload.team_name ?? null,
44
+ description: null,
45
+ },
46
+ lead: {
47
+ lead_agent_id: null,
48
+ lead_session_id: null,
49
+ },
50
+ ...(payload.include_members !== false ? { members: [] } : {}),
51
+ ...(payload.include_paths !== false
52
+ ? {
53
+ paths: {
54
+ config_path: null,
55
+ tasks_dir: null,
56
+ inboxes_dir: null,
57
+ tasks_dir_resolution: TEAM_BRIDGE_NOT_REGISTERED,
58
+ },
59
+ }
60
+ : {}),
61
+ bridge_installed: false,
62
+ skipped: true,
63
+ },
64
+ };
65
+ }
66
+
67
+ function teamTaskListFallback() {
68
+ return {
69
+ ok: true,
70
+ data: {
71
+ tasks: [],
72
+ count: 0,
73
+ parse_warnings: 0,
74
+ tasks_dir: null,
75
+ tasks_dir_resolution: TEAM_BRIDGE_NOT_REGISTERED,
76
+ bridge_installed: false,
77
+ skipped: true,
78
+ },
79
+ };
80
+ }
81
+
82
+ function teamTaskUpdateFallback(payload = {}) {
83
+ return {
84
+ ok: true,
85
+ data: {
86
+ claimed: false,
87
+ updated: false,
88
+ task_before: null,
89
+ task_after: null,
90
+ task_file: null,
91
+ task_id: payload.task_id ?? null,
92
+ mtime_ms: null,
93
+ bridge_installed: false,
94
+ skipped: true,
95
+ },
96
+ };
97
+ }
98
+
99
+ function teamSendMessageFallback(payload = {}) {
100
+ return {
101
+ ok: true,
102
+ data: {
103
+ message_id: null,
104
+ recipient: payload.to ?? 'team-lead',
105
+ inbox_file: null,
106
+ queued_at: null,
107
+ unread_count: 0,
108
+ bridge_installed: false,
109
+ skipped: true,
110
+ },
111
+ };
112
+ }
113
+
37
114
  /**
38
115
  * Named Pipe 서버 생성
39
116
  * @param {object} opts
@@ -241,13 +318,19 @@ export function createPipeServer({
241
318
  }
242
319
 
243
320
  case 'team_task_update': {
244
- const result = await teamTaskUpdate(payload);
321
+ const teamTaskUpdate = getTeamBridgeMethod('teamTaskUpdate');
322
+ const result = teamTaskUpdate
323
+ ? await teamTaskUpdate(payload)
324
+ : teamTaskUpdateFallback(payload);
245
325
  if (client) touchClient(client);
246
326
  return result;
247
327
  }
248
328
 
249
329
  case 'team_send_message': {
250
- const result = await teamSendMessage(payload);
330
+ const teamSendMessage = getTeamBridgeMethod('teamSendMessage');
331
+ const result = teamSendMessage
332
+ ? await teamSendMessage(payload)
333
+ : teamSendMessageFallback(payload);
251
334
  if (client) touchClient(client);
252
335
  return result;
253
336
  }
@@ -363,13 +446,15 @@ export function createPipeServer({
363
446
  }
364
447
 
365
448
  case 'team_info': {
366
- const result = await teamInfo(payload);
449
+ const teamInfo = getTeamBridgeMethod('teamInfo');
450
+ const result = teamInfo ? await teamInfo(payload) : teamInfoFallback(payload);
367
451
  if (client) touchClient(client);
368
452
  return result;
369
453
  }
370
454
 
371
455
  case 'team_task_list': {
372
- const result = await teamTaskList(payload);
456
+ const teamTaskList = getTeamBridgeMethod('teamTaskList');
457
+ const result = teamTaskList ? await teamTaskList(payload) : teamTaskListFallback(payload);
373
458
  if (client) touchClient(client);
374
459
  return result;
375
460
  }