@neta-art/cohub-cli 6.9.0 → 6.10.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.
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { resolveOpenSurface } from "@neta-art/cohub";
|
|
2
2
|
import type { Command } from "commander";
|
|
3
|
-
|
|
4
|
-
* The surface a desktop.open should request: an explicit `--as` wins, then
|
|
5
|
-
* whatever the App declared at publish time. `window` is the implicit default
|
|
6
|
-
* and yields `undefined` so the command stays compact.
|
|
7
|
-
*/
|
|
8
|
-
export declare function resolveOpenSurface(requested: string | undefined, declared: unknown): DesktopSurface | undefined;
|
|
3
|
+
export { resolveOpenSurface };
|
|
9
4
|
export declare function registerDesktop(program: Command): void;
|
|
10
5
|
export declare function registerLegacyUi(program: Command): void;
|
package/dist/commands/desktop.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { readFileSync } from "node:fs";
|
|
2
|
-
import { HttpError, } from "@neta-art/cohub";
|
|
3
|
-
import { parseAppRef, DESKTOP_COMMAND_DEFAULT_TIMEOUT_MS, DESKTOP_COMMAND_MAX_TIMEOUT_MS, } from "@neta-art/cohub";
|
|
2
|
+
import { HttpError, parseAppRef, resolveOpenSurface, DESKTOP_COMMAND_DEFAULT_TIMEOUT_MS, DESKTOP_COMMAND_MAX_TIMEOUT_MS, } from "@neta-art/cohub";
|
|
4
3
|
import { createClient } from "../client.js";
|
|
5
4
|
import { error, handleHttp, json as outJson, jsonRequested, ok } from "../output.js";
|
|
6
5
|
import { getAppByRef } from "../app-ref.js";
|
|
6
|
+
export { resolveOpenSurface };
|
|
7
7
|
const FILE_SCHEME = "file://";
|
|
8
8
|
const APP_SCHEME = "app://";
|
|
9
9
|
const LEGACY_WORK_SCHEME = "work://";
|
|
@@ -65,14 +65,6 @@ function parseTimeout(value) {
|
|
|
65
65
|
}
|
|
66
66
|
return parsed;
|
|
67
67
|
}
|
|
68
|
-
/**
|
|
69
|
-
* The surface a desktop.open should request: an explicit `--as` wins, then
|
|
70
|
-
* whatever the App declared at publish time. `window` is the implicit default
|
|
71
|
-
* and yields `undefined` so the command stays compact.
|
|
72
|
-
*/
|
|
73
|
-
export function resolveOpenSurface(requested, declared) {
|
|
74
|
-
return (requested ?? declared) === "overlay" ? "overlay" : undefined;
|
|
75
|
-
}
|
|
76
68
|
async function resolveAppTarget(client, ref) {
|
|
77
69
|
const normalized = hasAppScheme(ref) ? ref.replace(/^[a-zA-Z]+:\/\//, "") : ref;
|
|
78
70
|
const parsed = parseAppRef(normalized);
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Command } from "commander";
|
|
2
|
+
import { createClient } from "../client.js";
|
|
3
|
+
export declare function parseBody(raw: string | undefined): unknown;
|
|
4
|
+
/** `cohub spaces webhooks` — inbound HTTP triggers declared by `.cohub/hooks/<name>` with `on.event: webhook`. */
|
|
5
|
+
export declare function registerSpaceWebhooks(spacesCmd: Command, deps?: {
|
|
6
|
+
createClient?: typeof createClient;
|
|
7
|
+
}): void;
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { joinApiUrl, resolveApiBaseUrl } from "@neta-art/cohub";
|
|
2
|
+
import { createClient } from "../client.js";
|
|
3
|
+
import { error, handleHttp, json as outJson, jsonRequested, ok, table } from "../output.js";
|
|
4
|
+
import { resolveSpace } from "../space.js";
|
|
5
|
+
export function parseBody(raw) {
|
|
6
|
+
if (raw === undefined)
|
|
7
|
+
return null;
|
|
8
|
+
try {
|
|
9
|
+
return JSON.parse(raw);
|
|
10
|
+
}
|
|
11
|
+
catch {
|
|
12
|
+
return error("Invalid body", "--body must be JSON");
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
/** `cohub spaces webhooks` — inbound HTTP triggers declared by `.cohub/hooks/<name>` with `on.event: webhook`. */
|
|
16
|
+
export function registerSpaceWebhooks(spacesCmd, deps = {}) {
|
|
17
|
+
const client = () => (deps.createClient ?? createClient)();
|
|
18
|
+
const webhooksCmd = spacesCmd
|
|
19
|
+
.command("webhooks")
|
|
20
|
+
.description("Inbound webhooks declared by .cohub/hooks/<name> (on.event: webhook)");
|
|
21
|
+
webhooksCmd
|
|
22
|
+
.command("ls")
|
|
23
|
+
.alias("list")
|
|
24
|
+
.description("List declared webhooks")
|
|
25
|
+
.option("--json", "Output as JSON")
|
|
26
|
+
.action(async (opts) => {
|
|
27
|
+
const spaceId = await resolveSpace(spacesCmd);
|
|
28
|
+
try {
|
|
29
|
+
const result = await client().space(spaceId).webhooks.list();
|
|
30
|
+
if (jsonRequested(opts))
|
|
31
|
+
return outJson(result.items);
|
|
32
|
+
table(result.items, [
|
|
33
|
+
{ key: "name", label: "Name" },
|
|
34
|
+
{ key: "action", label: "Action" },
|
|
35
|
+
{ key: "hasSecret", label: "Secret" },
|
|
36
|
+
]);
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
handleHttp(e);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
webhooksCmd
|
|
43
|
+
.command("url <name>")
|
|
44
|
+
.description("Print the URL external services should POST to")
|
|
45
|
+
.option("--json", "Output as JSON")
|
|
46
|
+
.action(async (name, opts) => {
|
|
47
|
+
const spaceId = await resolveSpace(spacesCmd);
|
|
48
|
+
const sdk = client();
|
|
49
|
+
const url = joinApiUrl(resolveApiBaseUrl({}), sdk.space(spaceId).webhooks.path(name));
|
|
50
|
+
if (jsonRequested(opts))
|
|
51
|
+
return outJson({ name, url });
|
|
52
|
+
process.stdout.write(`${url}\n`);
|
|
53
|
+
});
|
|
54
|
+
webhooksCmd
|
|
55
|
+
.command("trigger <name>")
|
|
56
|
+
.description("POST a JSON body to a webhook hook (local testing)")
|
|
57
|
+
.option("--body <json>", "JSON body", "null")
|
|
58
|
+
.option("--secret <secret>", "Value for on.secret")
|
|
59
|
+
.option("--json", "Output as JSON")
|
|
60
|
+
.action(async (name, opts) => {
|
|
61
|
+
const spaceId = await resolveSpace(spacesCmd);
|
|
62
|
+
const body = parseBody(opts.body);
|
|
63
|
+
try {
|
|
64
|
+
const result = await client().space(spaceId).webhooks.trigger(name, body, { secret: opts.secret });
|
|
65
|
+
if (jsonRequested(opts))
|
|
66
|
+
return outJson(result);
|
|
67
|
+
ok(`Triggered ${result.hook} — task ${result.taskRunId}`);
|
|
68
|
+
}
|
|
69
|
+
catch (e) {
|
|
70
|
+
handleHttp(e);
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
}
|
package/dist/commands/spaces.js
CHANGED
|
@@ -11,6 +11,7 @@ import { registerSpaceCommerce } from "./space-commerce.js";
|
|
|
11
11
|
import { registerSpaceActivity } from "./space-activity.js";
|
|
12
12
|
import { registerSpaceInvitations } from "./space-invitations.js";
|
|
13
13
|
import { registerSpaceTurns } from "./space-turns.js";
|
|
14
|
+
import { registerSpaceWebhooks } from "./space-webhooks.js";
|
|
14
15
|
const cliEnv = resolveCohubEnvironment();
|
|
15
16
|
const defaultIdleTtlSeconds = cliEnv === "prod" ? 12 * 60 * 60 : 10 * 60;
|
|
16
17
|
const SPACE_ROLES = ["host", "builder", "guest"];
|
|
@@ -659,6 +660,8 @@ export function registerSpaces(program) {
|
|
|
659
660
|
registerMods(spacesCmd);
|
|
660
661
|
// ── spaces labels ──
|
|
661
662
|
registerLabels(spacesCmd);
|
|
663
|
+
// ── spaces webhooks ──
|
|
664
|
+
registerSpaceWebhooks(spacesCmd);
|
|
662
665
|
// ── spaces pin / unpin (user-scope label convenience) ──
|
|
663
666
|
spacesCmd
|
|
664
667
|
.command("pin <id>")
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@neta-art/cohub-cli",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.10.0",
|
|
4
4
|
"description": "CLI for Cohub — spaces, sessions, and agent collaboration.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
"NOTICE"
|
|
16
16
|
],
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@neta-art/generation": "^0.1.
|
|
18
|
+
"@neta-art/generation": "^0.1.26",
|
|
19
19
|
"commander": "^15.0.0",
|
|
20
20
|
"pixi.js": "^8.20.1",
|
|
21
21
|
"sharp": "^0.35.4",
|
|
22
|
-
"@neta-art/cohub": "8.
|
|
22
|
+
"@neta-art/cohub": "8.13.0"
|
|
23
23
|
},
|
|
24
24
|
"publishConfig": {
|
|
25
25
|
"access": "public"
|