@opencraw/studio 0.0.34 → 0.0.37

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 (33) hide show
  1. package/dist/index.d.ts +3 -1
  2. package/dist/index.esm.js +937 -653
  3. package/dist/src/index.d.ts +3 -1
  4. package/dist/src/studio-api/command.contract.d.ts +69 -0
  5. package/dist/src/studio-api/event.contract.d.ts +31 -0
  6. package/dist/src/studio-api/index.d.ts +8 -4
  7. package/dist/src/studio-api/studio-control-view.contract.d.ts +53 -0
  8. package/dist/src/studio-api/ui-request.contract.d.ts +15 -0
  9. package/dist/src/studio-instance/index.d.ts +3 -0
  10. package/dist/src/studio-instance/instance-file.repository.d.ts +14 -0
  11. package/dist/src/studio-instance/studio-instance.contract.d.ts +15 -0
  12. package/dist/src/studio-server/ask-ui.handler.d.ts +32 -0
  13. package/dist/src/studio-server/run-status.handler.d.ts +12 -0
  14. package/dist/src/studio-server/studio-http.use-case.d.ts +2 -0
  15. package/dist/src/studio-server/studio-status.handler.d.ts +10 -0
  16. package/dist/src/studio-server/workspace.store.d.ts +5 -1
  17. package/dist/studio-api/command.contract.d.ts +69 -0
  18. package/dist/studio-api/event.contract.d.ts +31 -0
  19. package/dist/studio-api/index.d.ts +8 -4
  20. package/dist/studio-api/studio-control-view.contract.d.ts +53 -0
  21. package/dist/studio-api/ui-request.contract.d.ts +15 -0
  22. package/dist/studio-instance/index.d.ts +3 -0
  23. package/dist/studio-instance/instance-file.repository.d.ts +14 -0
  24. package/dist/studio-instance/studio-instance.contract.d.ts +15 -0
  25. package/dist/studio-server/ask-ui.handler.d.ts +32 -0
  26. package/dist/studio-server/run-status.handler.d.ts +12 -0
  27. package/dist/studio-server/studio-http.use-case.d.ts +2 -0
  28. package/dist/studio-server/studio-status.handler.d.ts +10 -0
  29. package/dist/studio-server/workspace.store.d.ts +5 -1
  30. package/dist/ui/assets/{index-Db6-8OgZ.js → index-B40d4kiB.js} +26 -26
  31. package/dist/ui/assets/{pdf-rdp2xUbL.js → pdf-DS2CRtYv.js} +1 -1
  32. package/dist/ui/index.html +1 -1
  33. package/package.json +3 -3
@@ -0,0 +1,15 @@
1
+ import { z } from 'zod';
2
+ /** What an outside controller (an agent, through the MCP server) can ask the open Studio page to do. Grows one `kind` at a time. */
3
+ export declare const uiRequestSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
4
+ kind: z.ZodLiteral<"open">;
5
+ path: z.ZodString;
6
+ workspace: z.ZodOptional<z.ZodString>;
7
+ }, z.core.$strip>, z.ZodObject<{
8
+ kind: z.ZodLiteral<"pick">;
9
+ recipeId: z.ZodString;
10
+ selector: z.ZodOptional<z.ZodString>;
11
+ text: z.ZodOptional<z.ZodString>;
12
+ add: z.ZodOptional<z.ZodBoolean>;
13
+ }, z.core.$strip>], "kind">;
14
+ export type UiRequest = z.infer<typeof uiRequestSchema>;
15
+ //# sourceMappingURL=ui-request.contract.d.ts.map
@@ -0,0 +1,3 @@
1
+ export { announceInstance, defaultInstancesDirectory, withdrawInstance } from './instance-file.repository';
2
+ export type { StudioInstance } from './studio-instance.contract';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,14 @@
1
+ import type { StudioInstance } from './studio-instance.contract';
2
+ /** Where running Studios announce themselves, unless the caller says otherwise. */
3
+ export declare function defaultInstancesDirectory(): string;
4
+ /**
5
+ * Writes the file that tells controllers this Studio is running. Failing to write it never stops Studio: it only means no agent can find it.
6
+ *
7
+ * @param instance - What to announce.
8
+ * @param directory - Where announcements live.
9
+ * @returns Whether the file was written.
10
+ */
11
+ export declare function announceInstance(instance: StudioInstance, directory: string): Promise<boolean>;
12
+ /** Removes the announcement, when Studio stops. */
13
+ export declare function withdrawInstance(instance: Pick<StudioInstance, 'pid' | 'url'>, directory: string): Promise<void>;
14
+ //# sourceMappingURL=instance-file.repository.d.ts.map
@@ -0,0 +1,15 @@
1
+ /**
2
+ * What a running Studio tells the machine about itself, one file per process, so a controller that did not start it (the MCP server an
3
+ * agent talks to) can find it: `~/.opencraw/studio/<pid>.json`. The token is in it, so the file is readable by its owner only.
4
+ * `@opencraw/mcp` reads the same shape (`studio-control`); change both together.
5
+ */
6
+ export interface StudioInstance {
7
+ pid: number;
8
+ /** The server's address, without the token: `http://127.0.0.1:<port>`. */
9
+ url: string;
10
+ token: string;
11
+ /** The folder Studio was started with, if any; the live one is asked with `studio-status`. */
12
+ folder?: string;
13
+ startedAt: string;
14
+ }
15
+ //# sourceMappingURL=studio-instance.contract.d.ts.map
@@ -0,0 +1,32 @@
1
+ import type { AskUiCommand, AskUiView, UiOutcomeCommand, UiOutcomeView, UiReportCommand } from '../studio-api';
2
+ import type { StudioState } from './workspace.store';
3
+ /**
4
+ * Handles `ask-ui`: tells every open page what a controller (an agent, through the MCP server) asked for, so
5
+ * the person watching sees it happen. Nothing is done server-side: the page does it the way a click would, and
6
+ * says how it went (`ui-report`).
7
+ *
8
+ * @param state - The server state holding the connected pages.
9
+ * @param command - What to ask the pages.
10
+ * @returns How many pages were listening (0 means nobody has Studio open) and the id to ask the outcome with.
11
+ */
12
+ export declare function handleAskUi(state: StudioState, command: AskUiCommand): AskUiView;
13
+ /**
14
+ * Handles `ui-report`: a page says how a controller's request went. The first answer stays: every open page gets the
15
+ * request, and a page that has nothing to do with it (another recipe open) does not report.
16
+ *
17
+ * @param state - The server state.
18
+ * @param command - The request's id and the outcome.
19
+ * @returns Whether the report was kept.
20
+ */
21
+ export declare function handleUiReport(state: StudioState, command: UiReportCommand): {
22
+ kept: boolean;
23
+ };
24
+ /**
25
+ * Handles `ui-outcome`: how a controller's request went.
26
+ *
27
+ * @param state - The server state.
28
+ * @param command - The request's id.
29
+ * @returns `pending` until a page reported, then what it said.
30
+ */
31
+ export declare function handleUiOutcome(state: StudioState, command: UiOutcomeCommand): UiOutcomeView;
32
+ //# sourceMappingURL=ask-ui.handler.d.ts.map
@@ -0,0 +1,12 @@
1
+ import type { RunStatusCommand, RunStatusView } from '../studio-api';
2
+ import type { StudioState } from './workspace.store';
3
+ /**
4
+ * Handles `run-status`: how a recipe's sample run is going, for a controller that started it and cannot watch
5
+ * the event stream. A run in progress is `running`; one that finished carries its counts and first records.
6
+ *
7
+ * @param state - The server state holding the run in progress and the last runs.
8
+ * @param command - The recipe asked about.
9
+ * @returns The state of the recipe's sample run.
10
+ */
11
+ export declare function handleRunStatus(state: StudioState, command: RunStatusCommand): RunStatusView;
12
+ //# sourceMappingURL=run-status.handler.d.ts.map
@@ -21,6 +21,8 @@ export interface StudioServerOptions {
21
21
  chooseFolder?: () => Promise<string | undefined>;
22
22
  /** Where the studio's own recorder profile lives (issue #95); default: a fixed directory under the OS temp folder, never a crawl's own profile directory, never the person's default browser. */
23
23
  recorderProfileDir?: string;
24
+ /** Where this Studio announces itself so an agent's MCP server can find it (`studio-instance`); default: `~/.opencraw/studio`. */
25
+ instancesDir?: string;
24
26
  }
25
27
  /** The running server: its URL (token included, ready to open), the token alone, and how to stop it. */
26
28
  export interface StudioServer {
@@ -0,0 +1,10 @@
1
+ import type { StudioStatusView } from '../studio-api';
2
+ import type { StudioState } from './workspace.store';
3
+ /**
4
+ * Handles `studio-status`: what Studio is doing right now.
5
+ *
6
+ * @param state - The server state.
7
+ * @returns The open workspace, how many pages are open and the recipe being sampled.
8
+ */
9
+ export declare function handleStudioStatus(state: StudioState): StudioStatusView;
10
+ //# sourceMappingURL=studio-status.handler.d.ts.map
@@ -2,17 +2,21 @@ import type { BrowserSessionConfig } from '@opencraw/core';
2
2
  import type { RecorderSessionHandle } from '../flow-recording';
3
3
  import type { SnapshotCache } from '../page-snapshot';
4
4
  import type { LastRunCache, SampleRunHandle } from '../sample-run';
5
- import type { StudioEvent } from '../studio-api';
5
+ import type { StudioEvent, UiOutcomeView } from '../studio-api';
6
6
  import type { TrustedPlugins } from '../trusted-plugins';
7
7
  import type { WsConnection } from './websocket.client';
8
8
  /** The server's mutable state: the opened folder, the run in progress (if any), the recording in progress (if any, issue #95), the connected event sockets, the per-recipe snapshot cache `take-snapshot`/`verify-selector`/`infer-selector` share, each recipe's last finished sample run (`explain-why`, issue #92), the browser launch settings every web-mode command (`take-snapshot`, `verify-selector`, `run-sample`, `start-recording`) shares, and where the studio's own recorder profile lives. */
9
9
  export interface StudioState {
10
10
  folder?: string;
11
11
  activeRun?: SampleRunHandle;
12
+ /** The recipe `activeRun` is sampling. */
13
+ activeRunId?: string;
12
14
  activeRecording?: RecorderSessionHandle;
13
15
  /** A `start-recording` still opening its window: `stop-recording` and the server's own close wait for it, so a window is never left open behind them (issue #174). */
14
16
  openingRecording?: Promise<unknown>;
15
17
  sockets: Set<WsConnection>;
18
+ /** How the pages said a controller's requests went (`ui-report`), by request id; the oldest are dropped past a few dozen. */
19
+ uiOutcomes: Map<string, UiOutcomeView>;
16
20
  snapshots: SnapshotCache;
17
21
  lastRuns: LastRunCache;
18
22
  /** Set once at server start (`StudioServerOptions.browser`); every web-mode command reads it from here rather than each accepting its own. */