@neta-art/cohub-cli 10.14.1 → 10.16.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.
Files changed (48) hide show
  1. package/README.md +3 -1
  2. package/dist/auth.d.ts +3 -1
  3. package/dist/auth.js +4 -0
  4. package/dist/board-export.d.ts +7 -0
  5. package/dist/board-export.js +3 -3
  6. package/dist/board-kernel.d.ts +1 -0
  7. package/dist/board-kernel.js +7605 -277
  8. package/dist/board-simulate.d.ts +53 -0
  9. package/dist/board-simulate.js +151 -0
  10. package/dist/bootstrap.js +5 -0
  11. package/dist/commands/auth.js +12 -1
  12. package/dist/commands/boards.js +68 -0
  13. package/dist/commands/host.d.ts +2 -0
  14. package/dist/commands/host.js +11 -0
  15. package/dist/commands/runtime.js +4 -16
  16. package/dist/commands/space-invitations.d.ts +3 -2
  17. package/dist/commands/space-invitations.js +29 -8
  18. package/dist/commands/spaces.js +55 -30
  19. package/dist/host/auth.d.ts +20 -0
  20. package/dist/host/auth.js +107 -0
  21. package/dist/host/login-env.d.ts +1 -0
  22. package/dist/host/login-env.js +31 -0
  23. package/dist/host/runtime.d.ts +25 -0
  24. package/dist/host/runtime.js +250 -0
  25. package/dist/host/runtimes.d.ts +9 -0
  26. package/dist/host/runtimes.js +42 -0
  27. package/dist/host/serve.d.ts +2 -0
  28. package/dist/host/serve.js +73 -0
  29. package/dist/index.js +2 -0
  30. package/dist/runtime/connection.d.ts +3 -0
  31. package/dist/runtime/connection.js +59 -3
  32. package/dist/runtime/harnesses/claude.js +8 -2
  33. package/dist/runtime/harnesses/index.d.ts +2 -0
  34. package/dist/runtime/harnesses/index.js +13 -0
  35. package/dist/runtime/harnesses/stream-json.d.ts +2 -2
  36. package/dist/runtime/harnesses/stream-json.js +5 -3
  37. package/dist/runtime/harnesses/types.d.ts +4 -2
  38. package/dist/runtime/harnesses/workbuddy.d.ts +8 -2
  39. package/dist/runtime/instance.d.ts +8 -1
  40. package/dist/runtime/instance.js +89 -9
  41. package/dist/runtime/launch.d.ts +1 -0
  42. package/dist/runtime/launch.js +6 -0
  43. package/dist/runtime/model-catalog.d.ts +1 -3
  44. package/dist/runtime/model-catalog.js +23 -7
  45. package/dist/runtime/supervisor.js +6 -4
  46. package/dist/space.d.ts +1 -0
  47. package/dist/space.js +1 -1
  48. package/package.json +3 -3
package/README.md CHANGED
@@ -122,8 +122,10 @@ cohub spaces create --name "<name>" --checkpoint <checkpointId> --json
122
122
  cohub spaces update <spaceId> --slug <space-slug>
123
123
  cohub spaces rename <spaceId> "<new name>"
124
124
  cohub -s <spaceId> spaces invites create --role builder --days 7
125
- cohub -s <spaceId> spaces invites ls
125
+ cohub -s <spaceId> spaces invites create --role guest --never-expires
126
+ cohub -s <spaceId> spaces invites ls --all
126
127
  cohub -s <spaceId> spaces invites revoke <code> --yes
128
+ cohub spaces config <spaceId> --guest-app <app>
127
129
  cohub -s <spaceId> run -- git status
128
130
  ```
129
131
 
package/dist/auth.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { type CohubEnvironment } from "@neta-art/cohub";
2
2
  export type AuthSource = "execution-token" | "logto" | null;
3
- type DeviceCode = {
3
+ export type DeviceCode = {
4
4
  deviceCode: string;
5
5
  userCode: string;
6
6
  verificationUri: string;
@@ -29,6 +29,7 @@ export declare class AuthRequiredError extends Error {
29
29
  constructor(message?: string);
30
30
  }
31
31
  export declare const readAuthSession: () => AuthSession | null;
32
+ export declare const authSessionPath: () => string;
32
33
  export declare const clearAuthSession: (env?: CohubEnvironment, baseUrl?: string) => void;
33
34
  export declare const authSource: () => AuthSource;
34
35
  export declare function resolveAccessToken(options?: {
@@ -39,5 +40,6 @@ export declare function refreshAccessToken(session?: AuthSession | null): Promis
39
40
  export declare function requestDeviceCode(): Promise<DeviceCode>;
40
41
  export declare function verifyDeviceCode(): Promise<AuthSession>;
41
42
  export declare function loginWithDeviceFlow(onCode: (code: DeviceCode) => void, onPoll?: () => void): Promise<AuthSession>;
43
+ export declare function pollDeviceCode(code: DeviceCode, onPoll?: () => void): Promise<AuthSession>;
42
44
  export declare function revokeAndClearAuthSession(): Promise<void>;
43
45
  export {};
package/dist/auth.js CHANGED
@@ -129,6 +129,7 @@ const toSession = (token, config, env, previous) => {
129
129
  };
130
130
  };
131
131
  export const readAuthSession = () => readJson(sessionPath());
132
+ export const authSessionPath = () => sessionPath();
132
133
  export const clearAuthSession = (env = currentEnv(), baseUrl = resolveApiBaseUrl({ env })) => {
133
134
  removeIfExists(sessionPath(env, baseUrl));
134
135
  removeIfExists(deviceCodePath(env, baseUrl));
@@ -262,6 +263,9 @@ export async function verifyDeviceCode() {
262
263
  export async function loginWithDeviceFlow(onCode, onPoll) {
263
264
  const code = await requestDeviceCode();
264
265
  onCode(code);
266
+ return pollDeviceCode(code, onPoll);
267
+ }
268
+ export async function pollDeviceCode(code, onPoll) {
265
269
  while (Date.now() < code.expiresAt) {
266
270
  await delay(code.interval * 1000);
267
271
  onPoll?.();
@@ -1,5 +1,7 @@
1
1
  import type { BoardDocument, BoardExportRegion, BoardSceneItem, BoardThemeId } from "@neta-art/cohub/board";
2
2
  import type { BoardNodeExportFormat, BoardNodeFont, BoardNodeTexture } from "@neta-art/cohub/board/export/node";
3
+ import type { BoardScriptHost } from "@neta-art/cohub/board/render";
4
+ import { createClient } from "./client.js";
3
5
  import { type BoardExportDecodeImage } from "./board-export-resources.js";
4
6
  export declare function resolveBundledFonts(): BoardNodeFont[];
5
7
  export type BoardExportSource = {
@@ -33,6 +35,10 @@ export declare function loadBoardTextures(images: {
33
35
  }): Promise<{
34
36
  textures: Map<string, BoardNodeTexture>;
35
37
  } & Record<"failed" | "unavailable" | "omitted", string[]>>;
38
+ export declare function readSpaceFileBytes(client: ReturnType<typeof createClient>, spaceId: string, path: string): Promise<{
39
+ bytes: Uint8Array;
40
+ mimeType: string;
41
+ }>;
36
42
  export type BoardExportRunOptions = {
37
43
  spaceId: string;
38
44
  target: string;
@@ -51,6 +57,7 @@ export type BoardExportRunOptions = {
51
57
  height: number;
52
58
  };
53
59
  document?: BoardDocument;
60
+ scripts?: BoardScriptHost;
54
61
  signal?: AbortSignal;
55
62
  imageMemoryMiB?: number;
56
63
  onPlan?: (plan: {
@@ -152,7 +152,7 @@ async function fetchBoardPicture(client, spaceId, source, item, edge) {
152
152
  }
153
153
  return source.kind === "url" ? downloadPublicImage(source.value) : readSpaceFileBytes(client, spaceId, source.value);
154
154
  }
155
- async function readSpaceFileBytes(client, spaceId, path) {
155
+ export async function readSpaceFileBytes(client, spaceId, path) {
156
156
  const { blob, mimeType } = await client.space(spaceId).files.download(path);
157
157
  return { bytes: new Uint8Array(await blob.arrayBuffer()), mimeType };
158
158
  }
@@ -321,7 +321,7 @@ export async function runBoardExport(options) {
321
321
  warnings.push("The board background image could not be loaded; the fallback color was exported.");
322
322
  }
323
323
  }
324
- if (hasBoardScripts(document))
324
+ if (!options.scripts && hasBoardScripts(document))
325
325
  scriptHost = createNodeBoardScriptHost(renderer, {
326
326
  concurrency: 2,
327
327
  readModule: async (src) => {
@@ -382,7 +382,7 @@ export async function runBoardExport(options) {
382
382
  ...theme,
383
383
  background: options.background,
384
384
  textures,
385
- scripts: scriptHost ?? undefined,
385
+ scripts: options.scripts ?? scriptHost ?? undefined,
386
386
  backgroundTexture,
387
387
  assetKey,
388
388
  format: options.format,
@@ -2,3 +2,4 @@ export { BOARD_SCRIPT_DRAWING_EXAMPLE, hasBoardScripts, boardAssetKey, boardAsse
2
2
  export { prepareBoardExport } from "@neta-art/cohub/board/export";
3
3
  export { boardRenderTheme, createBoardRenderSampler, inspectBoardScene, inspectBoardItems, measureBoardText } from "@neta-art/cohub/board/render";
4
4
  export { createNodeBoardRenderer, createNodeBoardScriptHost, exportBoardImageBytes } from "@neta-art/cohub/board/export/node";
5
+ export { createBoardScriptHarness } from "@neta-art/cohub/board/testing";