@tensor-cad/mcp 0.1.1 → 0.1.3

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/artifacts.d.ts ADDED
@@ -0,0 +1,46 @@
1
+ /**
2
+ * Where generated files go.
3
+ *
4
+ * `tensorcad_generate_code` emits a PyTorch module and the design that
5
+ * produced it. Given no destination it hands the contents back in the reply,
6
+ * which is fine for one small file and useless for anything an agent wants to
7
+ * run — a model it cannot put anywhere is a model it can only read.
8
+ *
9
+ * Locally the destination is a directory, and writing to it is two lines of
10
+ * `node:fs`. Hosted, there is no filesystem at all: a Worker has no `mkdir`,
11
+ * and a file written into an isolate is gone when that isolate is. So the
12
+ * destination is an interface, and the only thing the tool knows about it is
13
+ * that it takes a path and some text and says where they went.
14
+ *
15
+ * ## The reply says where, not what
16
+ *
17
+ * `location` is for a person reading the transcript — an absolute path, or an
18
+ * object key. `url` is what makes a hosted sink worth having: something the
19
+ * agent can actually fetch. A sink that has no meaningful URL omits it rather
20
+ * than inventing one, because a link that does not resolve is worse than no
21
+ * link.
22
+ */
23
+ /** One emitted file, once it has been put somewhere. */
24
+ export interface WrittenArtifact {
25
+ /** Where it went, in whatever terms the sink uses. */
26
+ location: string;
27
+ /** Somewhere it can be fetched from, when the sink has one. */
28
+ url?: string;
29
+ }
30
+ export interface ArtifactSink {
31
+ /**
32
+ * A short name for the place, for the sentence the tool writes.
33
+ *
34
+ * "disk" and "object storage" read very differently in a transcript, and the
35
+ * difference matters to whoever has to go and find the file.
36
+ */
37
+ readonly label: string;
38
+ /**
39
+ * Put one file somewhere.
40
+ *
41
+ * `prefix` is whatever the caller passed as `out_dir`, uninterpreted: a
42
+ * directory to a filesystem, a key prefix to a bucket. `path` is the file's
43
+ * own relative path, which may contain directories.
44
+ */
45
+ write(prefix: string, path: string, contents: string): Promise<WrittenArtifact>;
46
+ }
@@ -94,6 +94,27 @@ export declare class BridgeServer {
94
94
  private attach;
95
95
  private handle;
96
96
  private mirror;
97
+ /**
98
+ * Run `work` with this socket marked as the one causing the change.
99
+ *
100
+ * `acting` is how a change is attributed to the connection that caused it,
101
+ * so the editor is not sent back the document it just sent.
102
+ *
103
+ * ## The flag is held across the call, not across the promise
104
+ *
105
+ * The store's mutating calls return promises now, and the obvious rewrite is
106
+ * `try { return await work() } finally { acting = undefined }`. That is
107
+ * wrong in a way no test here catches, because it holds the flag for longer
108
+ * than the thing it is protecting: `subscribe` promises the listener fires
109
+ * *synchronously*, inside the call, before anything is awaited — so the only
110
+ * window that matters is the synchronous part of `work()`.
111
+ *
112
+ * Holding it across the await instead opens a window in which a second
113
+ * message can arrive, set `acting` to its own socket, and then have this
114
+ * call's `finally` clear it — attributing that message's change to nobody.
115
+ * Clearing it the moment `work()` yields cannot do that, because nothing
116
+ * else runs during a synchronous call.
117
+ */
97
118
  private during;
98
119
  private send;
99
120
  }
package/index.d.ts CHANGED
@@ -10,7 +10,20 @@
10
10
  export { serve } from "./serve.js";
11
11
  export { createServer, SERVER_NAME, SERVER_VERSION } from "./server.js";
12
12
  export { FileStore } from "./store/file-store.js";
13
- export type { DocumentStore, DesignRecord, DesignSummary } from "./store/types.js";
13
+ export { DiskSink } from "./store/disk-artifacts.js";
14
+ export type { ArtifactSink, WrittenArtifact } from "./artifacts.js";
15
+ /**
16
+ * Everything it takes to *be* a store, not just to hold one.
17
+ *
18
+ * `DocumentStore` alone is not implementable from outside this package: the
19
+ * two errors are part of its contract — a caller distinguishes a revision
20
+ * conflict from an unknown id by catching them — and the option and outcome
21
+ * shapes appear in its signatures. Exporting the interface without them is
22
+ * exporting a shape nobody else can satisfy, which is what the hosted server
23
+ * found on its first attempt.
24
+ */
25
+ export { RevisionConflictError, UnknownDesignError, } from "./store/types.js";
26
+ export type { DocumentStore, DesignRecord, DesignSummary, DesignSource, ApplyOutcome, CheckpointInfo, NewDesignOptions, StoreChange, StoreListener, } from "./store/types.js";
14
27
  export { TOOL_NAMES } from "./tools.js";
15
28
  export { PROMPT_NAMES } from "./prompts.js";
16
29
  export { applyOps, type Op } from "./ops.js";