@cultured_computer/sight 0.3.6 → 0.4.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/dist/cli.js +87 -0
- package/package.json +5 -2
package/dist/cli.js
ADDED
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
// src/cli.ts
|
|
4
|
+
var DEFAULT_API = "https://fieldwork-ingest.fly.dev";
|
|
5
|
+
function flag(args, name) {
|
|
6
|
+
const i = args.indexOf(name);
|
|
7
|
+
return i === -1 ? null : args[i + 1] ?? null;
|
|
8
|
+
}
|
|
9
|
+
function usage() {
|
|
10
|
+
console.log(
|
|
11
|
+
[
|
|
12
|
+
"sight \u2014 the observer for agent conversations",
|
|
13
|
+
"",
|
|
14
|
+
"Usage:",
|
|
15
|
+
" sight connect <relay-url> --invite <code> [--pulse] [--api <base>]",
|
|
16
|
+
"",
|
|
17
|
+
" connect attach Sight to a buzz room as a read-only observer.",
|
|
18
|
+
" --invite one single-use invite code, minted by you on",
|
|
19
|
+
" your relay (its admin surface, or",
|
|
20
|
+
" POST /api/invites as the community owner).",
|
|
21
|
+
" Your invite is the authorization: Sight can",
|
|
22
|
+
" never enter a room you did not invite it into.",
|
|
23
|
+
" --pulse opt into the daily in-room readout (off by",
|
|
24
|
+
" default; counts, times, and links only).",
|
|
25
|
+
"",
|
|
26
|
+
"The SDK half of this package (serving-path capture) is documented at",
|
|
27
|
+
"https://field.cultured.computer/docs \u2014 the two lanes share one project."
|
|
28
|
+
].join("\n")
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
async function connect(args) {
|
|
32
|
+
const relayUrl = args.find((a) => !a.startsWith("-"));
|
|
33
|
+
const invite = flag(args, "--invite");
|
|
34
|
+
const api = (flag(args, "--api") ?? process.env["SIGHT_API"] ?? DEFAULT_API).replace(/\/+$/, "");
|
|
35
|
+
if (!relayUrl) {
|
|
36
|
+
console.error("connect needs a relay URL. Try: sight connect https://your-relay.example --invite <code>");
|
|
37
|
+
return 1;
|
|
38
|
+
}
|
|
39
|
+
if (!invite) {
|
|
40
|
+
console.error(
|
|
41
|
+
[
|
|
42
|
+
"connect needs --invite <code> \u2014 one single-use invite, minted by you.",
|
|
43
|
+
"On your relay: the community admin surface, or POST /api/invites as owner.",
|
|
44
|
+
"This stays manual on purpose: your community, your authority."
|
|
45
|
+
].join("\n")
|
|
46
|
+
);
|
|
47
|
+
return 1;
|
|
48
|
+
}
|
|
49
|
+
let res;
|
|
50
|
+
try {
|
|
51
|
+
res = await fetch(`${api}/v1/connections`, {
|
|
52
|
+
method: "POST",
|
|
53
|
+
headers: { "content-type": "application/json" },
|
|
54
|
+
body: JSON.stringify({ relayUrl, inviteCode: invite, pulse: args.includes("--pulse") })
|
|
55
|
+
});
|
|
56
|
+
} catch (err) {
|
|
57
|
+
console.error(`could not reach ${api}: ${err instanceof Error ? err.message : err}`);
|
|
58
|
+
return 1;
|
|
59
|
+
}
|
|
60
|
+
const body = await res.json().catch(() => ({}));
|
|
61
|
+
if (!res.ok) {
|
|
62
|
+
console.error(`connect failed (${res.status}): ${body["error"] ?? "unknown error"}`);
|
|
63
|
+
return 1;
|
|
64
|
+
}
|
|
65
|
+
if (body["status"] === "already-connected") {
|
|
66
|
+
console.log(`this relay is already connected. ${body["note"] ?? ""}`);
|
|
67
|
+
console.log(`deployment: ${body["deploymentSlug"]}`);
|
|
68
|
+
if (body["claimUrl"]) console.log(`claim/archive: ${body["claimUrl"]}`);
|
|
69
|
+
return 0;
|
|
70
|
+
}
|
|
71
|
+
console.log("connected. sight is observing your room.");
|
|
72
|
+
console.log(` deployment: ${body["deploymentSlug"]}`);
|
|
73
|
+
console.log(` first sync: ${body["firstSync"]}`);
|
|
74
|
+
console.log(` room pulse: ${body["pulse"]} ${body["pulse"] === "off" ? "(re-run with --pulse, or toggle after claiming)" : ""}`);
|
|
75
|
+
console.log("");
|
|
76
|
+
console.log("the archive (sessions, measurements, the label queue) attaches when");
|
|
77
|
+
console.log("you claim \u2014 keep this link, it is the only copy:");
|
|
78
|
+
console.log(` ${body["claimUrl"]}`);
|
|
79
|
+
return 0;
|
|
80
|
+
}
|
|
81
|
+
var [, , command, ...rest] = process.argv;
|
|
82
|
+
if (command === "connect") {
|
|
83
|
+
connect(rest).then((code) => process.exit(code));
|
|
84
|
+
} else {
|
|
85
|
+
usage();
|
|
86
|
+
process.exit(command && command !== "--help" && command !== "-h" ? 1 : 0);
|
|
87
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cultured_computer/sight",
|
|
3
|
-
"version": "0.
|
|
4
|
-
"
|
|
3
|
+
"version": "0.4.0",
|
|
4
|
+
"bin": {
|
|
5
|
+
"sight": "./dist/cli.js"
|
|
6
|
+
},
|
|
7
|
+
"description": "The standard format for agent experience data: every step your production AI takes and what comes back, in one published, versioned record \u2014 behavioural measurements on top, no evals, captured out of band.",
|
|
5
8
|
"license": "MIT",
|
|
6
9
|
"type": "module",
|
|
7
10
|
"main": "./dist/index.cjs",
|