@neta-art/cohub-cli 10.24.0 → 10.25.1
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/bin/cohub.js +4 -1
- package/dist/board-gpu/page.js +1566 -71230
- package/dist/bootstrap.js +67 -27
- package/dist/build.json +1 -1
- package/dist/{board-kernel/FilterPipe.js → chunks/Geometry.js} +10447 -10469
- package/dist/chunks/about.js +102 -0
- package/dist/chunks/app-realtime.js +2216 -0
- package/dist/chunks/app-realtime2.js +2 -0
- package/dist/chunks/app-ref.js +88 -0
- package/dist/chunks/apps.js +1423 -0
- package/dist/chunks/auth.js +175 -0
- package/dist/chunks/avatar.js +146 -0
- package/dist/chunks/binary-pins.js +5 -0
- package/dist/chunks/board-export-resources.js +232 -0
- package/dist/chunks/board-export.js +874 -0
- package/dist/chunks/board-export2.js +2 -0
- package/dist/{board-kernel.js → chunks/board-kernel.js} +18032 -28512
- package/dist/chunks/board-kernel2.js +4 -0
- package/dist/chunks/board-profile.js +69 -0
- package/dist/chunks/board-simulate.js +315 -0
- package/dist/chunks/board-time.js +34 -0
- package/dist/chunks/boards.js +1943 -0
- package/dist/{board-kernel → chunks}/browserAll.js +9 -8
- package/dist/chunks/channels.js +64 -0
- package/dist/chunks/client.js +12606 -0
- package/dist/chunks/command-input.js +17 -0
- package/dist/chunks/commander.js +2962 -0
- package/dist/chunks/cron-jobs.js +163 -0
- package/dist/chunks/daemon.js +545 -0
- package/dist/chunks/daemon2.js +2 -0
- package/dist/chunks/desktop.js +172 -0
- package/dist/chunks/endpoint-options.js +26 -0
- package/dist/chunks/env-proxy.js +35 -0
- package/dist/chunks/environment.js +154 -0
- package/dist/chunks/feedback.js +120 -0
- package/dist/chunks/generations.js +379 -0
- package/dist/chunks/host.js +9 -0
- package/dist/chunks/http-put.js +131 -0
- package/dist/chunks/id.js +2416 -0
- package/dist/{board-kernel → chunks}/init.js +1 -1
- package/dist/chunks/install.js +11959 -0
- package/dist/chunks/launch.js +374 -0
- package/dist/chunks/local-media.js +47 -0
- package/dist/chunks/me.js +134 -0
- package/dist/chunks/media.js +315 -0
- package/dist/chunks/models.js +242 -0
- package/dist/chunks/operands.js +46 -0
- package/dist/chunks/package-paths.js +13 -0
- package/dist/chunks/policy.js +221 -0
- package/dist/chunks/preferences.js +29 -0
- package/dist/chunks/profile.js +64 -0
- package/dist/chunks/prompts.js +41 -0
- package/dist/chunks/public.js +2 -0
- package/dist/chunks/public2.js +244 -0
- package/dist/chunks/references.js +197 -0
- package/dist/chunks/referrals.js +90 -0
- package/dist/chunks/rolldown-runtime.js +26 -0
- package/dist/chunks/rooms-connect.js +2 -0
- package/dist/chunks/rooms-connect2.js +151 -0
- package/dist/chunks/rooms-rtc.js +311 -0
- package/dist/chunks/rooms.js +211 -0
- package/dist/chunks/run.js +220 -0
- package/dist/chunks/runtime.js +638 -0
- package/dist/chunks/runtime2.js +286 -0
- package/dist/chunks/runtimes.js +48 -0
- package/dist/chunks/safe-remote-image.js +198 -0
- package/dist/chunks/schemas.js +6017 -0
- package/dist/chunks/search.js +113 -0
- package/dist/chunks/self-update.js +238 -0
- package/dist/chunks/serve.js +1246 -0
- package/dist/chunks/session-status.js +24 -0
- package/dist/chunks/skills.js +35 -0
- package/dist/chunks/spaces.js +5080 -0
- package/dist/chunks/src.js +405 -0
- package/dist/chunks/supervisor.js +2513 -0
- package/dist/chunks/supervisor2.js +2 -0
- package/dist/chunks/tasks.js +82 -0
- package/dist/chunks/themes.js +2898 -0
- package/dist/chunks/version.js +2 -0
- package/dist/chunks/version2.js +22 -0
- package/dist/chunks/version3.js +18 -0
- package/dist/chunks/web.js +7 -0
- package/dist/{board-kernel → chunks}/webworkerAll.js +1 -1
- package/dist/runtime/native/pi-extension.js +174 -166
- package/dist/runtime/worker.js +27 -16
- package/package.json +8 -9
- package/dist/about.d.ts +0 -2
- package/dist/about.js +0 -71
- package/dist/app-download.d.ts +0 -11
- package/dist/app-download.js +0 -252
- package/dist/app-ref.d.ts +0 -5
- package/dist/app-ref.js +0 -8
- package/dist/app-target.d.ts +0 -26
- package/dist/app-target.js +0 -55
- package/dist/auth.d.ts +0 -45
- package/dist/auth.js +0 -307
- package/dist/avatar.d.ts +0 -55
- package/dist/avatar.js +0 -104
- package/dist/board-command-support.d.ts +0 -6
- package/dist/board-command-support.js +0 -88
- package/dist/board-export-resources.d.ts +0 -12
- package/dist/board-export-resources.js +0 -51
- package/dist/board-export.d.ts +0 -110
- package/dist/board-export.js +0 -592
- package/dist/board-fonts.d.ts +0 -11
- package/dist/board-fonts.js +0 -10
- package/dist/board-gpu/daemon.d.ts +0 -11
- package/dist/board-gpu/daemon.js +0 -295
- package/dist/board-gpu/index.d.ts +0 -33
- package/dist/board-gpu/index.js +0 -189
- package/dist/board-gpu/protocol.d.ts +0 -77
- package/dist/board-gpu/protocol.js +0 -1
- package/dist/board-kernel.d.ts +0 -5
- package/dist/board-media-export.d.ts +0 -17
- package/dist/board-media-export.js +0 -164
- package/dist/board-media.d.ts +0 -5
- package/dist/board-media.js +0 -66
- package/dist/board-profile.d.ts +0 -21
- package/dist/board-profile.js +0 -67
- package/dist/board-simulate.d.ts +0 -67
- package/dist/board-simulate.js +0 -259
- package/dist/board-time.d.ts +0 -3
- package/dist/board-time.js +0 -34
- package/dist/bootstrap.d.ts +0 -2
- package/dist/client.d.ts +0 -5
- package/dist/client.js +0 -24
- package/dist/command-input.d.ts +0 -4
- package/dist/command-input.js +0 -16
- package/dist/commands/app-commerce.d.ts +0 -2
- package/dist/commands/app-commerce.js +0 -228
- package/dist/commands/app-domains.d.ts +0 -2
- package/dist/commands/app-domains.js +0 -133
- package/dist/commands/apps.d.ts +0 -4
- package/dist/commands/apps.js +0 -827
- package/dist/commands/auth.d.ts +0 -2
- package/dist/commands/auth.js +0 -186
- package/dist/commands/boards/authoring.d.ts +0 -2
- package/dist/commands/boards/authoring.js +0 -166
- package/dist/commands/boards/examples.d.ts +0 -10
- package/dist/commands/boards/examples.js +0 -118
- package/dist/commands/boards.d.ts +0 -13
- package/dist/commands/boards.js +0 -836
- package/dist/commands/channels.d.ts +0 -2
- package/dist/commands/channels.js +0 -74
- package/dist/commands/cron-jobs.d.ts +0 -2
- package/dist/commands/cron-jobs.js +0 -155
- package/dist/commands/decision.d.ts +0 -4
- package/dist/commands/decision.js +0 -113
- package/dist/commands/desktop.d.ts +0 -10
- package/dist/commands/desktop.js +0 -233
- package/dist/commands/feedback.d.ts +0 -2
- package/dist/commands/feedback.js +0 -131
- package/dist/commands/generations.d.ts +0 -2
- package/dist/commands/generations.js +0 -427
- package/dist/commands/host.d.ts +0 -2
- package/dist/commands/host.js +0 -11
- package/dist/commands/me.d.ts +0 -2
- package/dist/commands/me.js +0 -121
- package/dist/commands/models.d.ts +0 -28
- package/dist/commands/models.js +0 -271
- package/dist/commands/profile.d.ts +0 -2
- package/dist/commands/profile.js +0 -81
- package/dist/commands/prompts.d.ts +0 -2
- package/dist/commands/prompts.js +0 -37
- package/dist/commands/public.d.ts +0 -20
- package/dist/commands/public.js +0 -291
- package/dist/commands/references.d.ts +0 -2
- package/dist/commands/references.js +0 -193
- package/dist/commands/referrals.d.ts +0 -2
- package/dist/commands/referrals.js +0 -88
- package/dist/commands/rooms-connect.d.ts +0 -17
- package/dist/commands/rooms-connect.js +0 -140
- package/dist/commands/rooms-rtc-binary.d.ts +0 -2
- package/dist/commands/rooms-rtc-binary.js +0 -107
- package/dist/commands/rooms-rtc.d.ts +0 -21
- package/dist/commands/rooms-rtc.js +0 -171
- package/dist/commands/rooms.d.ts +0 -3
- package/dist/commands/rooms.js +0 -277
- package/dist/commands/run.d.ts +0 -13
- package/dist/commands/run.js +0 -246
- package/dist/commands/runtime.d.ts +0 -3
- package/dist/commands/runtime.js +0 -320
- package/dist/commands/sandboxd-binary.d.ts +0 -11
- package/dist/commands/sandboxd-binary.js +0 -238
- package/dist/commands/search.d.ts +0 -2
- package/dist/commands/search.js +0 -114
- package/dist/commands/session-access.d.ts +0 -2
- package/dist/commands/session-access.js +0 -70
- package/dist/commands/skills.d.ts +0 -2
- package/dist/commands/skills.js +0 -34
- package/dist/commands/space-activity.d.ts +0 -26
- package/dist/commands/space-activity.js +0 -147
- package/dist/commands/space-commerce.d.ts +0 -2
- package/dist/commands/space-commerce.js +0 -514
- package/dist/commands/space-displays.d.ts +0 -2
- package/dist/commands/space-displays.js +0 -620
- package/dist/commands/space-files.d.ts +0 -5
- package/dist/commands/space-files.js +0 -215
- package/dist/commands/space-invitations.d.ts +0 -29
- package/dist/commands/space-invitations.js +0 -189
- package/dist/commands/space-turns.d.ts +0 -49
- package/dist/commands/space-turns.js +0 -205
- package/dist/commands/space-wallet.d.ts +0 -2
- package/dist/commands/space-wallet.js +0 -141
- package/dist/commands/space-webhooks.d.ts +0 -7
- package/dist/commands/space-webhooks.js +0 -73
- package/dist/commands/spaces.d.ts +0 -25
- package/dist/commands/spaces.js +0 -2170
- package/dist/commands/tasks.d.ts +0 -8
- package/dist/commands/tasks.js +0 -80
- package/dist/commands/version.d.ts +0 -2
- package/dist/commands/version.js +0 -21
- package/dist/endpoint-options.d.ts +0 -4
- package/dist/endpoint-options.js +0 -26
- package/dist/env-proxy.d.ts +0 -5
- package/dist/env-proxy.js +0 -20
- package/dist/help-path.d.ts +0 -18
- package/dist/help-path.js +0 -223
- package/dist/host/auth.d.ts +0 -20
- package/dist/host/auth.js +0 -119
- package/dist/host/login-env.d.ts +0 -1
- package/dist/host/login-env.js +0 -31
- package/dist/host/runtime.d.ts +0 -35
- package/dist/host/runtime.js +0 -395
- package/dist/host/runtimes.d.ts +0 -9
- package/dist/host/runtimes.js +0 -42
- package/dist/host/serve.d.ts +0 -2
- package/dist/host/serve.js +0 -117
- package/dist/host/workspaces.d.ts +0 -2
- package/dist/host/workspaces.js +0 -18
- package/dist/http-put.d.ts +0 -25
- package/dist/http-put.js +0 -132
- package/dist/index.d.ts +0 -2
- package/dist/index.js +0 -129
- package/dist/launcher.d.ts +0 -4
- package/dist/launcher.js +0 -38
- package/dist/local-media.d.ts +0 -2
- package/dist/local-media.js +0 -30
- package/dist/network-error.d.ts +0 -3
- package/dist/network-error.js +0 -22
- package/dist/output.d.ts +0 -46
- package/dist/output.js +0 -244
- package/dist/runtime/archive-store.d.ts +0 -54
- package/dist/runtime/archive-store.js +0 -379
- package/dist/runtime/cli-path.d.ts +0 -5
- package/dist/runtime/cli-path.js +0 -27
- package/dist/runtime/codex-usage.d.ts +0 -7
- package/dist/runtime/codex-usage.js +0 -11
- package/dist/runtime/connection.d.ts +0 -42
- package/dist/runtime/connection.js +0 -789
- package/dist/runtime/diagnostics.d.ts +0 -107
- package/dist/runtime/diagnostics.js +0 -392
- package/dist/runtime/harnesses/chained-projection.d.ts +0 -40
- package/dist/runtime/harnesses/chained-projection.js +0 -95
- package/dist/runtime/harnesses/chained-transcript.d.ts +0 -24
- package/dist/runtime/harnesses/chained-transcript.js +0 -62
- package/dist/runtime/harnesses/claude-approval.d.ts +0 -34
- package/dist/runtime/harnesses/claude-approval.js +0 -124
- package/dist/runtime/harnesses/claude-transcript.d.ts +0 -8
- package/dist/runtime/harnesses/claude-transcript.js +0 -138
- package/dist/runtime/harnesses/claude.d.ts +0 -8
- package/dist/runtime/harnesses/claude.js +0 -225
- package/dist/runtime/harnesses/codex-approval.d.ts +0 -25
- package/dist/runtime/harnesses/codex-approval.js +0 -69
- package/dist/runtime/harnesses/codex.d.ts +0 -4
- package/dist/runtime/harnesses/codex.js +0 -269
- package/dist/runtime/harnesses/cursor-transcript.d.ts +0 -37
- package/dist/runtime/harnesses/cursor-transcript.js +0 -183
- package/dist/runtime/harnesses/cursor.d.ts +0 -24
- package/dist/runtime/harnesses/cursor.js +0 -620
- package/dist/runtime/harnesses/index.d.ts +0 -16
- package/dist/runtime/harnesses/index.js +0 -73
- package/dist/runtime/harnesses/pi.d.ts +0 -4
- package/dist/runtime/harnesses/pi.js +0 -247
- package/dist/runtime/harnesses/process.d.ts +0 -31
- package/dist/runtime/harnesses/process.js +0 -75
- package/dist/runtime/harnesses/stream-json.d.ts +0 -48
- package/dist/runtime/harnesses/stream-json.js +0 -336
- package/dist/runtime/harnesses/types.d.ts +0 -117
- package/dist/runtime/harnesses/types.js +0 -1
- package/dist/runtime/harnesses/workbuddy-transcript.d.ts +0 -8
- package/dist/runtime/harnesses/workbuddy-transcript.js +0 -127
- package/dist/runtime/harnesses/workbuddy.d.ts +0 -21
- package/dist/runtime/harnesses/workbuddy.js +0 -123
- package/dist/runtime/instance.d.ts +0 -20
- package/dist/runtime/instance.js +0 -247
- package/dist/runtime/json-rpc.d.ts +0 -53
- package/dist/runtime/json-rpc.js +0 -212
- package/dist/runtime/launch.d.ts +0 -25
- package/dist/runtime/launch.js +0 -247
- package/dist/runtime/local-workspace.d.ts +0 -15
- package/dist/runtime/local-workspace.js +0 -52
- package/dist/runtime/model-catalog.d.ts +0 -12
- package/dist/runtime/model-catalog.js +0 -84
- package/dist/runtime/native/adapters.d.ts +0 -15
- package/dist/runtime/native/adapters.js +0 -11
- package/dist/runtime/native/approvals.d.ts +0 -18
- package/dist/runtime/native/approvals.js +0 -54
- package/dist/runtime/native/archive.d.ts +0 -19
- package/dist/runtime/native/archive.js +0 -142
- package/dist/runtime/native/attach.d.ts +0 -36
- package/dist/runtime/native/attach.js +0 -128
- package/dist/runtime/native/codex-link.d.ts +0 -60
- package/dist/runtime/native/codex-link.js +0 -322
- package/dist/runtime/native/config.d.ts +0 -16
- package/dist/runtime/native/config.js +0 -24
- package/dist/runtime/native/daemon.d.ts +0 -92
- package/dist/runtime/native/daemon.js +0 -380
- package/dist/runtime/native/execution.d.ts +0 -26
- package/dist/runtime/native/execution.js +0 -34
- package/dist/runtime/native/identity.d.ts +0 -9
- package/dist/runtime/native/identity.js +0 -15
- package/dist/runtime/native/ingest.d.ts +0 -263
- package/dist/runtime/native/ingest.js +0 -884
- package/dist/runtime/native/install.d.ts +0 -9
- package/dist/runtime/native/install.js +0 -113
- package/dist/runtime/native/paths.d.ts +0 -2
- package/dist/runtime/native/paths.js +0 -7
- package/dist/runtime/native/pi-extension.d.ts +0 -36
- package/dist/runtime/native/pi-link.d.ts +0 -69
- package/dist/runtime/native/pi-link.js +0 -269
- package/dist/runtime/native/results.d.ts +0 -41
- package/dist/runtime/native/results.js +0 -128
- package/dist/runtime/native/sessions.d.ts +0 -45
- package/dist/runtime/native/sessions.js +0 -87
- package/dist/runtime/native/transcript.d.ts +0 -89
- package/dist/runtime/native/transcript.js +0 -656
- package/dist/runtime/native/translate.d.ts +0 -46
- package/dist/runtime/native/translate.js +0 -299
- package/dist/runtime/native/transport.d.ts +0 -7
- package/dist/runtime/native/transport.js +0 -16
- package/dist/runtime/native/version.d.ts +0 -5
- package/dist/runtime/native/version.js +0 -21
- package/dist/runtime/preferences.d.ts +0 -7
- package/dist/runtime/preferences.js +0 -22
- package/dist/runtime/presentation.d.ts +0 -32
- package/dist/runtime/presentation.js +0 -124
- package/dist/runtime/process-group.d.ts +0 -5
- package/dist/runtime/process-group.js +0 -161
- package/dist/runtime/projection-store.d.ts +0 -27
- package/dist/runtime/projection-store.js +0 -30
- package/dist/runtime/space-binding.d.ts +0 -48
- package/dist/runtime/space-binding.js +0 -342
- package/dist/runtime/supervisor.d.ts +0 -19
- package/dist/runtime/supervisor.js +0 -441
- package/dist/runtime/turn-projection.d.ts +0 -41
- package/dist/runtime/turn-projection.js +0 -120
- package/dist/runtime/worker.d.ts +0 -1
- package/dist/safe-remote-image.d.ts +0 -36
- package/dist/safe-remote-image.js +0 -191
- package/dist/self-update.d.ts +0 -7
- package/dist/self-update.js +0 -202
- package/dist/session-status.d.ts +0 -10
- package/dist/session-status.js +0 -25
- package/dist/space-files/limit.d.ts +0 -2
- package/dist/space-files/limit.js +0 -16
- package/dist/space-files/operands.d.ts +0 -17
- package/dist/space-files/operands.js +0 -33
- package/dist/space-files/transfer.d.ts +0 -53
- package/dist/space-files/transfer.js +0 -297
- package/dist/space-files/upload.d.ts +0 -17
- package/dist/space-files/upload.js +0 -76
- package/dist/space.d.ts +0 -44
- package/dist/space.js +0 -192
- package/dist/version.d.ts +0 -2
- package/dist/version.js +0 -17
- package/dist/web.d.ts +0 -1
- package/dist/web.js +0 -4
- /package/dist/{board-kernel → chunks}/lexer.js +0 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
import { C as error, D as json, E as handleHttp, O as jsonRequested, T as formatLocalDateTime, j as table, st as isUuid, t as createClient } from "./client.js";
|
|
2
|
+
//#region src/commands/references.ts
|
|
3
|
+
const RESOURCE_TYPES = /* @__PURE__ */ new Set([
|
|
4
|
+
"turn",
|
|
5
|
+
"session",
|
|
6
|
+
"space",
|
|
7
|
+
"checkpoint"
|
|
8
|
+
]);
|
|
9
|
+
const REFERENCE_KINDS = /* @__PURE__ */ new Set([
|
|
10
|
+
"session_fork",
|
|
11
|
+
"space_fork",
|
|
12
|
+
"checkpoint_fork",
|
|
13
|
+
"mod",
|
|
14
|
+
"mention",
|
|
15
|
+
"tool_call",
|
|
16
|
+
"turn_trigger",
|
|
17
|
+
"agent_tool_file_read",
|
|
18
|
+
"agent_tool_file_write",
|
|
19
|
+
"agent_tool_file_edit",
|
|
20
|
+
"agent_tool_file_ls",
|
|
21
|
+
"agent_tool_file_find",
|
|
22
|
+
"agent_tool_file_grep"
|
|
23
|
+
]);
|
|
24
|
+
const DIRECTIONS = /* @__PURE__ */ new Set([
|
|
25
|
+
"out",
|
|
26
|
+
"in",
|
|
27
|
+
"both"
|
|
28
|
+
]);
|
|
29
|
+
const GROUP_BYS = /* @__PURE__ */ new Set([
|
|
30
|
+
"kind",
|
|
31
|
+
"targetType",
|
|
32
|
+
"target",
|
|
33
|
+
"sourceType",
|
|
34
|
+
"day"
|
|
35
|
+
]);
|
|
36
|
+
function parseSource(value) {
|
|
37
|
+
const idx = value.indexOf(":");
|
|
38
|
+
if (idx <= 0) throw new Error("Source must be <type>:<id>, e.g. session:<uuid>");
|
|
39
|
+
const type = value.slice(0, idx);
|
|
40
|
+
const id = value.slice(idx + 1).trim();
|
|
41
|
+
if (!RESOURCE_TYPES.has(type)) throw new Error(`Invalid resource type: ${type}`);
|
|
42
|
+
if (!id) throw new Error("Missing resource id");
|
|
43
|
+
return {
|
|
44
|
+
type,
|
|
45
|
+
id
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
function parseKinds(value) {
|
|
49
|
+
const kinds = value?.split(",").map((k) => k.trim()).filter(Boolean);
|
|
50
|
+
if (!kinds?.length) return void 0;
|
|
51
|
+
const invalid = kinds.find((k) => !REFERENCE_KINDS.has(k));
|
|
52
|
+
if (invalid) throw new Error(`Invalid reference kind: ${invalid}`);
|
|
53
|
+
return [...new Set(kinds)];
|
|
54
|
+
}
|
|
55
|
+
function clampNumber(value, fallback, min, max) {
|
|
56
|
+
const parsed = Number(value ?? fallback);
|
|
57
|
+
if (!Number.isFinite(parsed)) return fallback;
|
|
58
|
+
return Math.min(Math.max(Math.floor(parsed), min), max);
|
|
59
|
+
}
|
|
60
|
+
const KINDS_HELP = `Kinds:
|
|
61
|
+
structural: session_fork, space_fork, checkpoint_fork, mod
|
|
62
|
+
content: mention, tool_call
|
|
63
|
+
causality: turn_trigger
|
|
64
|
+
file access: agent_tool_file_read, agent_tool_file_write, agent_tool_file_edit,
|
|
65
|
+
agent_tool_file_ls, agent_tool_file_find, agent_tool_file_grep`;
|
|
66
|
+
function registerReferences(program) {
|
|
67
|
+
const references = program.command("references").description("Inspect resource references (forks, mentions, tool calls, mods, file access)").addHelpText("after", "\nAnalysis index for collaboration edges and file heat.\n");
|
|
68
|
+
references.command("query").description("List references touching a resource").argument("<source>", "turn:<uuid> | session:<uuid> | space:<uuid> | checkpoint:<uuid>").option("--direction <dir>", "out | in | both", "both").option("--kinds <kinds>", "Comma-separated kinds (see list below)").option("--days <n>", "Only references seen within the last N days").option("--limit <n>", "Maximum rows, 1-500", "200").option("--json", "Output as JSON").addHelpText("after", `
|
|
69
|
+
|
|
70
|
+
${KINDS_HELP}
|
|
71
|
+
|
|
72
|
+
Examples:
|
|
73
|
+
cohub references query turn:<uuid> --kinds agent_tool_file_read,agent_tool_file_write
|
|
74
|
+
cohub references query turn:<uuid> --direction out --kinds turn_trigger
|
|
75
|
+
cohub references query session:<uuid> --json
|
|
76
|
+
cohub references query checkpoint:<uuid> --direction out
|
|
77
|
+
cohub references query space:<uuid> --direction in --kinds mention,tool_call
|
|
78
|
+
cohub references query space:<uuid> --kinds agent_tool_file_read --days 30
|
|
79
|
+
`).action(async (source, opts) => {
|
|
80
|
+
const client = createClient();
|
|
81
|
+
try {
|
|
82
|
+
const ref = parseSource(source);
|
|
83
|
+
const direction = opts.direction ?? "both";
|
|
84
|
+
if (!DIRECTIONS.has(direction)) return error(`Invalid direction: ${opts.direction}`);
|
|
85
|
+
const kinds = parseKinds(opts.kinds);
|
|
86
|
+
const days = opts.days ? clampNumber(opts.days, 30, 1, 365) : void 0;
|
|
87
|
+
const limit = clampNumber(opts.limit, 200, 1, 500);
|
|
88
|
+
const result = await client.references.query({
|
|
89
|
+
source: `${ref.type}:${ref.id}`,
|
|
90
|
+
direction,
|
|
91
|
+
kinds,
|
|
92
|
+
days,
|
|
93
|
+
limit
|
|
94
|
+
});
|
|
95
|
+
if (jsonRequested(opts)) return json(result);
|
|
96
|
+
const rows = result.references.map((r) => ({
|
|
97
|
+
kind: r.kind,
|
|
98
|
+
source: `${r.sourceType}:${r.sourceId.slice(0, 8)}`,
|
|
99
|
+
target: formatTarget(r.targetType, r.targetId),
|
|
100
|
+
count: r.count,
|
|
101
|
+
lastSeen: formatLocalDateTime(r.updatedAt).slice(0, 10)
|
|
102
|
+
}));
|
|
103
|
+
table(rows, [
|
|
104
|
+
{
|
|
105
|
+
key: "kind",
|
|
106
|
+
label: "Kind"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
key: "source",
|
|
110
|
+
label: "Source"
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
key: "target",
|
|
114
|
+
label: "Target"
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
key: "count",
|
|
118
|
+
label: "Count"
|
|
119
|
+
},
|
|
120
|
+
{
|
|
121
|
+
key: "lastSeen",
|
|
122
|
+
label: "Last Seen"
|
|
123
|
+
}
|
|
124
|
+
]);
|
|
125
|
+
} catch (e) {
|
|
126
|
+
if (e instanceof Error && (e.message.startsWith("Invalid") || e.message.startsWith("Source must") || e.message.startsWith("Missing"))) return error(e.message);
|
|
127
|
+
handleHttp(e);
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
references.command("aggregate").description("Grouped reference counts for a space").argument("<spaceId>", "Space id").option("--group-by <field>", "kind | targetType | target | sourceType | day", "kind").option("--kinds <kinds>", "Comma-separated kinds (see list below)").option("--days <n>", "Only references seen within the last N days").option("--limit <n>", "Maximum groups, 1-500", "200").option("--json", "Output as JSON").addHelpText("after", `
|
|
131
|
+
|
|
132
|
+
${KINDS_HELP}
|
|
133
|
+
|
|
134
|
+
Notes:
|
|
135
|
+
--group-by target: file targets look like {spaceId}:{path}
|
|
136
|
+
|
|
137
|
+
Examples:
|
|
138
|
+
cohub references aggregate <spaceId> --json
|
|
139
|
+
cohub references aggregate <spaceId> --group-by targetType
|
|
140
|
+
cohub references aggregate <spaceId> --group-by target --kinds agent_tool_file_read --limit 20
|
|
141
|
+
cohub references aggregate <spaceId> --group-by day --days 30
|
|
142
|
+
`).action(async (spaceId, opts) => {
|
|
143
|
+
const client = createClient();
|
|
144
|
+
try {
|
|
145
|
+
if (!isUuid(spaceId.trim())) return error("Invalid space id");
|
|
146
|
+
const groupBy = opts.groupBy ?? "kind";
|
|
147
|
+
if (!GROUP_BYS.has(groupBy)) return error(`Invalid group-by: ${opts.groupBy}`);
|
|
148
|
+
const kinds = parseKinds(opts.kinds);
|
|
149
|
+
const days = opts.days ? clampNumber(opts.days, 30, 1, 365) : void 0;
|
|
150
|
+
const limit = clampNumber(opts.limit, 200, 1, 500);
|
|
151
|
+
const result = await client.references.aggregate({
|
|
152
|
+
spaceId: spaceId.trim(),
|
|
153
|
+
groupBy,
|
|
154
|
+
kinds,
|
|
155
|
+
days,
|
|
156
|
+
limit
|
|
157
|
+
});
|
|
158
|
+
if (jsonRequested(opts)) return json(result);
|
|
159
|
+
const rows = result.groups.map((g) => ({
|
|
160
|
+
group: g.group,
|
|
161
|
+
references: g.references,
|
|
162
|
+
total: g.total
|
|
163
|
+
}));
|
|
164
|
+
table(rows, [
|
|
165
|
+
{
|
|
166
|
+
key: "group",
|
|
167
|
+
label: "Group"
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
key: "references",
|
|
171
|
+
label: "References"
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
key: "total",
|
|
175
|
+
label: "Total"
|
|
176
|
+
}
|
|
177
|
+
]);
|
|
178
|
+
} catch (e) {
|
|
179
|
+
if (e instanceof Error && e.message.startsWith("Invalid")) return error(e.message);
|
|
180
|
+
handleHttp(e);
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Render a target for the table. File targets are `{spaceId}:{path}`; show the
|
|
186
|
+
* short space id plus the full path rather than blindly truncating.
|
|
187
|
+
*/
|
|
188
|
+
function formatTarget(targetType, targetId) {
|
|
189
|
+
if (targetType === "file") {
|
|
190
|
+
const idx = targetId.indexOf(":");
|
|
191
|
+
if (idx > 0) return `file:${targetId.slice(0, 8)}…${targetId.slice(idx)}`;
|
|
192
|
+
return `file:${targetId}`;
|
|
193
|
+
}
|
|
194
|
+
return `${targetType}:${targetId.slice(0, 8)}`;
|
|
195
|
+
}
|
|
196
|
+
//#endregion
|
|
197
|
+
export { registerReferences };
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { C as error, D as json, E as handleHttp, O as jsonRequested, T as formatLocalDateTime, j as table, k as ok, t as createClient } from "./client.js";
|
|
2
|
+
import { t as webUrl } from "./web.js";
|
|
3
|
+
//#region src/commands/referrals.ts
|
|
4
|
+
function referralUrl(code) {
|
|
5
|
+
return webUrl(`/referrals/${code}`);
|
|
6
|
+
}
|
|
7
|
+
async function confirmRotate(opts) {
|
|
8
|
+
if (opts.yes) return;
|
|
9
|
+
if (!process.stdin.isTTY || !process.stdout.isTTY) return error("Confirmation required", "Pass --yes to replace the referral link.");
|
|
10
|
+
process.stdout.write("The current referral link will stop working. Continue? [y/N] ");
|
|
11
|
+
const chunks = [];
|
|
12
|
+
for await (const chunk of process.stdin) {
|
|
13
|
+
chunks.push(chunk);
|
|
14
|
+
break;
|
|
15
|
+
}
|
|
16
|
+
const answer = Buffer.concat(chunks).toString().trim().toLowerCase();
|
|
17
|
+
if (answer !== "y" && answer !== "yes") return error("Cancelled");
|
|
18
|
+
}
|
|
19
|
+
function registerReferrals(program) {
|
|
20
|
+
const command = program.command("referrals").description("View and manage your referral link").option("--json", "Output as JSON").action(async (opts) => {
|
|
21
|
+
const client = createClient();
|
|
22
|
+
try {
|
|
23
|
+
const result = await client.referrals.getMine();
|
|
24
|
+
const output = {
|
|
25
|
+
...result,
|
|
26
|
+
url: referralUrl(result.code)
|
|
27
|
+
};
|
|
28
|
+
if (jsonRequested(opts)) return json(output);
|
|
29
|
+
console.log(`\nReferral link: ${output.url}`);
|
|
30
|
+
const { quota } = result;
|
|
31
|
+
const resets = quota.cycleEndsAt ? `, resets ${formatLocalDateTime(quota.cycleEndsAt)}` : "";
|
|
32
|
+
console.log(`Cycle: ${quota.used}/${quota.limit} used, ${quota.reserved} pending, ${quota.available} available${resets}`);
|
|
33
|
+
console.log(`Rewarded: ${result.summary.rewarded}`);
|
|
34
|
+
console.log(`Earned: $${result.summary.earnedUsd.toFixed(2)}\n`);
|
|
35
|
+
} catch (error) {
|
|
36
|
+
handleHttp(error);
|
|
37
|
+
}
|
|
38
|
+
});
|
|
39
|
+
command.command("ls").alias("list").description("List your referrals").option("--json", "Output as JSON").action(async (opts) => {
|
|
40
|
+
const client = createClient();
|
|
41
|
+
try {
|
|
42
|
+
const result = await client.referrals.getMine();
|
|
43
|
+
if (jsonRequested(opts)) return json(result);
|
|
44
|
+
table(result.items, [
|
|
45
|
+
{
|
|
46
|
+
key: "id",
|
|
47
|
+
label: "ID"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
key: "status",
|
|
51
|
+
label: "Status"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
key: "claimedAt",
|
|
55
|
+
label: "Claimed",
|
|
56
|
+
format: formatLocalDateTime
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
key: "expiresAt",
|
|
60
|
+
label: "Expires",
|
|
61
|
+
format: formatLocalDateTime
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
key: "rewardedAt",
|
|
65
|
+
label: "Rewarded",
|
|
66
|
+
format: formatLocalDateTime
|
|
67
|
+
}
|
|
68
|
+
]);
|
|
69
|
+
} catch (error) {
|
|
70
|
+
handleHttp(error);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
command.command("rotate").description("Replace your referral link").option("-y, --yes", "Confirm replacement").option("--json", "Output as JSON").action(async (opts) => {
|
|
74
|
+
await confirmRotate(opts);
|
|
75
|
+
const client = createClient();
|
|
76
|
+
try {
|
|
77
|
+
const result = await client.referrals.rotateCode();
|
|
78
|
+
const output = {
|
|
79
|
+
...result,
|
|
80
|
+
url: referralUrl(result.code)
|
|
81
|
+
};
|
|
82
|
+
if (jsonRequested(opts)) return json(output);
|
|
83
|
+
ok(`Referral link rotated: ${output.url}`);
|
|
84
|
+
} catch (error) {
|
|
85
|
+
handleHttp(error);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
//#endregion
|
|
90
|
+
export { registerReferrals };
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { createRequire } from "node:module";
|
|
2
|
+
//#region \0rolldown/runtime.js
|
|
3
|
+
var __create = Object.create;
|
|
4
|
+
var __defProp = Object.defineProperty;
|
|
5
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
7
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
8
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
9
|
+
var __commonJSMin = (cb, mod) => () => (mod || (cb((mod = { exports: {} }).exports, mod), cb = null), mod.exports);
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") for (var keys = __getOwnPropNames(from), i = 0, n = keys.length, key; i < n; i++) {
|
|
12
|
+
key = keys[i];
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except) __defProp(to, key, {
|
|
14
|
+
get: ((k) => from[k]).bind(null, key),
|
|
15
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
return to;
|
|
19
|
+
};
|
|
20
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(isNodeMode || !mod || !mod.__esModule || !__hasOwnProp.call(mod, "default") ? __defProp(target, "default", {
|
|
21
|
+
value: mod,
|
|
22
|
+
enumerable: true
|
|
23
|
+
}) : target, mod));
|
|
24
|
+
var __require = /* #__PURE__ */ (() => createRequire(import.meta.url))();
|
|
25
|
+
//#endregion
|
|
26
|
+
export { __require as n, __toESM as r, __commonJSMin as t };
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import { r as createRealtimeClient } from "./client.js";
|
|
2
|
+
//#region src/commands/rooms-connect.ts
|
|
3
|
+
const MAX_LINE_BYTES = 20480;
|
|
4
|
+
const MAX_OUTPUT_BUFFER_BYTES = 1048576;
|
|
5
|
+
function parseRoomInput(line) {
|
|
6
|
+
if (Buffer.byteLength(line) > MAX_LINE_BYTES) throw new Error("Room input line is too large");
|
|
7
|
+
let value;
|
|
8
|
+
try {
|
|
9
|
+
value = JSON.parse(line);
|
|
10
|
+
} catch {
|
|
11
|
+
throw new Error("Room input must be JSON");
|
|
12
|
+
}
|
|
13
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) throw new Error("Room input must be an object");
|
|
14
|
+
const input = value;
|
|
15
|
+
if (input.op === "presence" && (input.presence === null || typeof input.presence === "object" && !Array.isArray(input.presence))) return {
|
|
16
|
+
op: "presence",
|
|
17
|
+
presence: input.presence
|
|
18
|
+
};
|
|
19
|
+
if ((input.op === "publish" || input.op === "send") && typeof input.type === "string" && "data" in input) return {
|
|
20
|
+
op: input.op,
|
|
21
|
+
type: input.type,
|
|
22
|
+
data: input.data
|
|
23
|
+
};
|
|
24
|
+
throw new Error("Use {\"op\":\"publish|send\",\"type\":\"name\",\"data\":...} or {\"op\":\"presence\",\"presence\":...}");
|
|
25
|
+
}
|
|
26
|
+
async function* readRoomLines(input, maxBytes = MAX_LINE_BYTES) {
|
|
27
|
+
let pending = Buffer.alloc(0);
|
|
28
|
+
for await (const chunk of input) {
|
|
29
|
+
const bytes = Buffer.isBuffer(chunk) ? chunk : Buffer.from(chunk);
|
|
30
|
+
let start = 0;
|
|
31
|
+
for (;;) {
|
|
32
|
+
const end = bytes.indexOf(10, start);
|
|
33
|
+
const part = bytes.subarray(start, end < 0 ? bytes.length : end);
|
|
34
|
+
if (pending.length + part.length > maxBytes) throw new Error("Room input line is too large");
|
|
35
|
+
pending = pending.length ? Buffer.concat([pending, part]) : part;
|
|
36
|
+
if (end < 0) break;
|
|
37
|
+
yield pending.toString("utf8").replace(/\r$/, "");
|
|
38
|
+
pending = Buffer.alloc(0);
|
|
39
|
+
start = end + 1;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (pending.length) yield pending.toString("utf8");
|
|
43
|
+
}
|
|
44
|
+
async function connectToRoom(roomId, options) {
|
|
45
|
+
const after = options.after === void 0 ? void 0 : Number(options.after);
|
|
46
|
+
if (after !== void 0 && (!Number.isSafeInteger(after) || after < 0)) throw new Error("--after must be a non-negative sequence number");
|
|
47
|
+
const client = createRealtimeClient();
|
|
48
|
+
let room = null;
|
|
49
|
+
let stopped = false;
|
|
50
|
+
let finish;
|
|
51
|
+
const done = new Promise((resolve) => {
|
|
52
|
+
finish = resolve;
|
|
53
|
+
});
|
|
54
|
+
const stop = () => {
|
|
55
|
+
if (stopped) return;
|
|
56
|
+
stopped = true;
|
|
57
|
+
finish();
|
|
58
|
+
};
|
|
59
|
+
const write = (kind, value) => {
|
|
60
|
+
if (stopped) return;
|
|
61
|
+
if (process.stdout.writableLength > MAX_OUTPUT_BUFFER_BYTES) {
|
|
62
|
+
process.stderr.write("Room output is too slow; disconnecting.\n");
|
|
63
|
+
process.exitCode = 1;
|
|
64
|
+
stop();
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
process.stdout.write(options.json ? `${JSON.stringify({
|
|
68
|
+
kind,
|
|
69
|
+
...value
|
|
70
|
+
})}\n` : `${kind}: ${JSON.stringify(value)}\n`);
|
|
71
|
+
};
|
|
72
|
+
const onSignal = () => {
|
|
73
|
+
stop();
|
|
74
|
+
room?.disconnect().catch(() => void 0);
|
|
75
|
+
client.disconnect();
|
|
76
|
+
};
|
|
77
|
+
process.once("SIGINT", onSignal);
|
|
78
|
+
process.once("SIGTERM", onSignal);
|
|
79
|
+
let inputTask = null;
|
|
80
|
+
try {
|
|
81
|
+
room = await client.rooms.connect(roomId, {
|
|
82
|
+
after,
|
|
83
|
+
onRoom: (active) => {
|
|
84
|
+
room = active;
|
|
85
|
+
if (stopped) {
|
|
86
|
+
active.disconnect();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
active.subscribeAll((event) => write("event", { event }));
|
|
90
|
+
active.onMembersChanged((members) => write("members", { members }));
|
|
91
|
+
active.onOutOfSync((from, to) => write("gap", {
|
|
92
|
+
from,
|
|
93
|
+
to
|
|
94
|
+
}));
|
|
95
|
+
active.onSendError((failure) => write("error", { message: failure.message }));
|
|
96
|
+
active.onStateChange((state) => {
|
|
97
|
+
write("state", { state });
|
|
98
|
+
if (state === "closed" || state === "expired") stop();
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
if (!stopped) write("connected", {
|
|
103
|
+
roomId,
|
|
104
|
+
participantId: room.participantId,
|
|
105
|
+
sequence: room.sequence
|
|
106
|
+
});
|
|
107
|
+
if (!stopped && options.input) {
|
|
108
|
+
const active = room;
|
|
109
|
+
inputTask = (async () => {
|
|
110
|
+
let lineNumber = 0;
|
|
111
|
+
for await (const line of readRoomLines(process.stdin)) {
|
|
112
|
+
if (stopped) break;
|
|
113
|
+
lineNumber++;
|
|
114
|
+
if (!line.trim()) continue;
|
|
115
|
+
try {
|
|
116
|
+
const input = parseRoomInput(line);
|
|
117
|
+
if (input.op === "presence") await active.setPresence(input.presence);
|
|
118
|
+
else if (input.op === "send") active.send(input.type, input.data);
|
|
119
|
+
else {
|
|
120
|
+
const result = await active.publish(input.type, input.data);
|
|
121
|
+
write("ack", {
|
|
122
|
+
line: lineNumber,
|
|
123
|
+
sequence: result.sequence,
|
|
124
|
+
eventId: result.eventId
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
} catch (cause) {
|
|
128
|
+
write("input_error", {
|
|
129
|
+
line: lineNumber,
|
|
130
|
+
message: cause instanceof Error ? cause.message : String(cause)
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
})().catch((cause) => {
|
|
135
|
+
write("input_error", { message: cause instanceof Error ? cause.message : String(cause) });
|
|
136
|
+
process.exitCode = 1;
|
|
137
|
+
stop();
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
await done;
|
|
141
|
+
} finally {
|
|
142
|
+
if (options.input) process.stdin.destroy();
|
|
143
|
+
await room?.disconnect().catch(() => void 0);
|
|
144
|
+
await client.disconnect();
|
|
145
|
+
await inputTask?.catch(() => void 0);
|
|
146
|
+
process.removeListener("SIGINT", onSignal);
|
|
147
|
+
process.removeListener("SIGTERM", onSignal);
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
//#endregion
|
|
151
|
+
export { parseRoomInput as n, readRoomLines as r, connectToRoom as t };
|