trellis 3.1.20 → 3.1.30

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/dist/index.js CHANGED
@@ -1,4 +1,5 @@
1
1
  // @bun
2
+ import"./index-4gknc19b.js";
2
3
  import {
3
4
  FileWatcher,
4
5
  Ingestion,
@@ -11,7 +12,7 @@ import {
11
12
  loadProfile,
12
13
  saveProfile,
13
14
  writeAgentScaffold
14
- } from "./index-3qrxzwe4.js";
15
+ } from "./index-ncckgtrk.js";
15
16
  import {
16
17
  VcsMiddleware
17
18
  } from "./index-hy73j9z8.js";
@@ -0,0 +1,214 @@
1
+ // @bun
2
+ import {
3
+ TrellisVcsEngine,
4
+ init_engine
5
+ } from "./index-ncckgtrk.js";
6
+ import"./index-a2a394zz.js";
7
+ import"./index-65z0xfjw.js";
8
+ import"./index-v9b4hqa7.js";
9
+ import"./index-yhwjgfvj.js";
10
+ import"./index-a76rekgs.js";
11
+
12
+ // src/federation/remote-manager.ts
13
+ init_engine();
14
+ import { readFileSync, writeFileSync, existsSync, mkdirSync } from "fs";
15
+ import { join, resolve } from "path";
16
+
17
+ class RemoteManager {
18
+ trellisPath;
19
+ remotesPath;
20
+ constructor(trellisPath) {
21
+ this.trellisPath = trellisPath;
22
+ this.remotesPath = join(trellisPath, "remotes.json");
23
+ }
24
+ loadRemotes() {
25
+ if (!existsSync(this.remotesPath)) {
26
+ return { remotes: {} };
27
+ }
28
+ try {
29
+ const content = readFileSync(this.remotesPath, "utf8");
30
+ return JSON.parse(content);
31
+ } catch (error) {
32
+ throw new Error(`Failed to load remotes config: ${error}`);
33
+ }
34
+ }
35
+ saveRemotes(config) {
36
+ try {
37
+ if (!existsSync(this.trellisPath)) {
38
+ mkdirSync(this.trellisPath, { recursive: true });
39
+ }
40
+ writeFileSync(this.remotesPath, JSON.stringify(config, null, 2), "utf8");
41
+ } catch (error) {
42
+ throw new Error(`Failed to save remotes config: ${error}`);
43
+ }
44
+ }
45
+ addRemote(name, path) {
46
+ const config = this.loadRemotes();
47
+ if (config.remotes[name]) {
48
+ throw new Error(`Remote '${name}' already exists`);
49
+ }
50
+ const resolvedPath = resolve(path);
51
+ if (!TrellisVcsEngine.isRepo(resolvedPath)) {
52
+ throw new Error(`Not a TrellisVCS repository: ${resolvedPath}`);
53
+ }
54
+ config.remotes[name] = {
55
+ name,
56
+ path: resolvedPath
57
+ };
58
+ this.saveRemotes(config);
59
+ }
60
+ removeRemote(name) {
61
+ const config = this.loadRemotes();
62
+ if (!config.remotes[name]) {
63
+ throw new Error(`Remote '${name}' not found`);
64
+ }
65
+ delete config.remotes[name];
66
+ this.saveRemotes(config);
67
+ }
68
+ listRemotes() {
69
+ const config = this.loadRemotes();
70
+ return Object.values(config.remotes);
71
+ }
72
+ async pullRemote(remoteName, localEngine) {
73
+ const startTime = Date.now();
74
+ const config = this.loadRemotes();
75
+ const remote = config.remotes[remoteName];
76
+ if (!remote) {
77
+ throw new Error(`Remote '${remoteName}' not found`);
78
+ }
79
+ const errors = [];
80
+ let newOps = 0;
81
+ let latestOpId = remote.lastOpId || "";
82
+ try {
83
+ const remoteEngine = new TrellisVcsEngine({ rootPath: remote.path });
84
+ remoteEngine.open();
85
+ const remoteOps = remoteEngine.getOps();
86
+ if (remoteOps.length === 0) {
87
+ return {
88
+ remote: remoteName,
89
+ newOps: 0,
90
+ latestOpId: "",
91
+ durationMs: Date.now() - startTime,
92
+ errors: []
93
+ };
94
+ }
95
+ const lastOpHash = remote.lastOpId;
96
+ let startIndex = 0;
97
+ if (lastOpHash) {
98
+ startIndex = remoteOps.findIndex((op) => op.hash === lastOpHash);
99
+ if (startIndex === -1) {
100
+ startIndex = 0;
101
+ errors.push(`Last op hash ${lastOpHash} not found in remote, pulling all ops`);
102
+ } else {
103
+ startIndex++;
104
+ }
105
+ }
106
+ const opsToPull = remoteOps.slice(startIndex);
107
+ if (opsToPull.length > 0) {
108
+ const prefixedOps = opsToPull.map((op) => this.prefixOpEntities(op, remoteName));
109
+ for (const op of prefixedOps) {
110
+ localEngine.opLog.append(op);
111
+ newOps++;
112
+ }
113
+ latestOpId = remoteOps[remoteOps.length - 1].hash;
114
+ }
115
+ remote.lastOpId = latestOpId;
116
+ remote.pulledAt = new Date().toISOString();
117
+ this.saveRemotes(config);
118
+ } catch (error) {
119
+ errors.push(`Failed to pull from remote: ${error}`);
120
+ }
121
+ return {
122
+ remote: remoteName,
123
+ newOps,
124
+ latestOpId,
125
+ durationMs: Date.now() - startTime,
126
+ errors
127
+ };
128
+ }
129
+ async pullAll(localEngine) {
130
+ const config = this.loadRemotes();
131
+ const remoteNames = Object.keys(config.remotes);
132
+ if (remoteNames.length === 0) {
133
+ return {
134
+ results: [],
135
+ totalNewOps: 0,
136
+ totalDurationMs: 0
137
+ };
138
+ }
139
+ const startTime = Date.now();
140
+ const results = [];
141
+ let totalNewOps = 0;
142
+ for (const remoteName of remoteNames) {
143
+ try {
144
+ const result = await this.pullRemote(remoteName, localEngine);
145
+ results.push(result);
146
+ totalNewOps += result.newOps;
147
+ } catch (error) {
148
+ results.push({
149
+ remote: remoteName,
150
+ newOps: 0,
151
+ latestOpId: "",
152
+ durationMs: 0,
153
+ errors: [`Failed to pull: ${error}`]
154
+ });
155
+ }
156
+ }
157
+ return {
158
+ results,
159
+ totalNewOps,
160
+ totalDurationMs: Date.now() - startTime
161
+ };
162
+ }
163
+ prefixOpEntities(op, remoteName) {
164
+ const prefixed = { ...op };
165
+ if (op.vcs) {
166
+ const vcs = { ...op.vcs };
167
+ if (vcs.issueId && !vcs.issueId.includes(":")) {
168
+ vcs.issueId = `${remoteName}:${vcs.issueId}`;
169
+ }
170
+ if (vcs.parentIssueId && !vcs.parentIssueId.includes(":")) {
171
+ vcs.parentIssueId = `${remoteName}:${vcs.parentIssueId}`;
172
+ }
173
+ if (vcs.blockedByIssueId && !vcs.blockedByIssueId.includes(":")) {
174
+ vcs.blockedByIssueId = `${remoteName}:${vcs.blockedByIssueId}`;
175
+ }
176
+ if (vcs.decisionId && !vcs.decisionId.includes(":")) {
177
+ vcs.decisionId = `${remoteName}:${vcs.decisionId}`;
178
+ }
179
+ prefixed.vcs = vcs;
180
+ }
181
+ if (op.facts) {
182
+ prefixed.facts = op.facts.map((fact) => {
183
+ if (fact.e === "entity" && fact.a === "id" && typeof fact.v === "string" && !fact.v.includes(":")) {
184
+ return { ...fact, v: `${remoteName}:${fact.v}` };
185
+ }
186
+ if (fact.e === "entity" && fact.a === "from" && typeof fact.v === "string" && !fact.v.includes(":")) {
187
+ return { ...fact, v: `${remoteName}:${fact.v}` };
188
+ }
189
+ if (fact.e === "entity" && fact.a === "to" && typeof fact.v === "string" && !fact.v.includes(":")) {
190
+ return { ...fact, v: `${remoteName}:${fact.v}` };
191
+ }
192
+ return fact;
193
+ });
194
+ }
195
+ if (op.links) {
196
+ prefixed.links = op.links.map((link) => ({
197
+ ...link,
198
+ e1: link.e1.includes(":") ? link.e1 : `${remoteName}:${link.e1}`,
199
+ e2: link.e2.includes(":") ? link.e2 : `${remoteName}:${link.e2}`
200
+ }));
201
+ }
202
+ if (!prefixed.facts)
203
+ prefixed.facts = [];
204
+ prefixed.facts.push({
205
+ e: "op",
206
+ a: "remote",
207
+ v: remoteName
208
+ });
209
+ return prefixed;
210
+ }
211
+ }
212
+ export {
213
+ RemoteManager
214
+ };
@@ -1 +1 @@
1
- {"version":3,"file":"write.d.ts","sourceRoot":"","sources":["../../src/scaffold/write.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAIH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAMhD,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,SAAS,EAAE,MAAM,GAAG,IAAI,CAAC;IACzB,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,UAAU,EAAE,MAAM,EAAE,CAAC;IACrB,WA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
1
  // @bun
2
2
  import"../index-c9h37r6h.js";
3
+ import {
4
+ importFile,
5
+ importRecords
6
+ } from "../index-skhn0agf.js";
3
7
  import {
4
8
  deploy
5
9
  } from "../index-wt8rz4gn.js";
@@ -39,10 +43,6 @@ import {
39
43
  startServerCrossRuntime,
40
44
  verifyJwt
41
45
  } from "../index-53f3b8p8.js";
42
- import {
43
- importFile,
44
- importRecords
45
- } from "../index-skhn0agf.js";
46
46
  import"../index-n9f2qyh5.js";
47
47
  import"../index-xzym9w0m.js";
48
48
  import {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "trellis",
3
- "version": "3.1.20",
3
+ "version": "3.1.30",
4
4
  "description": "Agentic State Engine — event-sourced causal graph with branching, decision traces, and realtime sync for AI-native applications",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",