@monoes/monobrowse 1.0.0 → 1.0.2

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 (103) hide show
  1. package/dist/package.json +71 -0
  2. package/dist/src/browser/action-builder/analyzer.d.ts +0 -1
  3. package/dist/src/browser/action-builder/analyzer.d.ts.map +1 -1
  4. package/dist/src/browser/action-builder/analyzer.js +43 -21
  5. package/dist/src/browser/action-builder/analyzer.js.map +1 -1
  6. package/dist/src/browser/adapters/index.d.ts.map +1 -1
  7. package/dist/src/browser/adapters/index.js +4 -0
  8. package/dist/src/browser/adapters/index.js.map +1 -1
  9. package/dist/src/browser/browser.js +2 -2
  10. package/dist/src/browser/browser.js.map +1 -1
  11. package/dist/src/browser/cdp.d.ts +6 -0
  12. package/dist/src/browser/cdp.d.ts.map +1 -1
  13. package/dist/src/browser/cdp.js +56 -1
  14. package/dist/src/browser/cdp.js.map +1 -1
  15. package/dist/src/browser/dashboard/api-types.d.ts +1 -1
  16. package/dist/src/browser/dashboard/server.d.ts +12 -1
  17. package/dist/src/browser/dashboard/server.d.ts.map +1 -1
  18. package/dist/src/browser/dashboard/server.js +23 -28
  19. package/dist/src/browser/dashboard/server.js.map +1 -1
  20. package/dist/src/browser/dashboard/ui.html +1811 -0
  21. package/dist/src/browser/playbook/browser-handlers.d.ts +3 -0
  22. package/dist/src/browser/playbook/browser-handlers.d.ts.map +1 -0
  23. package/dist/src/browser/playbook/browser-handlers.js +377 -0
  24. package/dist/src/browser/playbook/browser-handlers.js.map +1 -0
  25. package/dist/src/browser/playbook/builtin-handlers.d.ts +3 -0
  26. package/dist/src/browser/playbook/builtin-handlers.d.ts.map +1 -0
  27. package/dist/src/browser/playbook/builtin-handlers.js +364 -0
  28. package/dist/src/browser/playbook/builtin-handlers.js.map +1 -0
  29. package/dist/src/browser/playbook/index.d.ts +3 -0
  30. package/dist/src/browser/playbook/index.d.ts.map +1 -0
  31. package/dist/src/browser/playbook/index.js +3 -0
  32. package/dist/src/browser/playbook/index.js.map +1 -0
  33. package/dist/src/browser/playbook/store.d.ts +8 -0
  34. package/dist/src/browser/playbook/store.d.ts.map +1 -0
  35. package/dist/src/browser/playbook/store.js +87 -0
  36. package/dist/src/browser/playbook/store.js.map +1 -0
  37. package/dist/src/browser/screenshot.d.ts +2 -0
  38. package/dist/src/browser/screenshot.d.ts.map +1 -1
  39. package/dist/src/browser/screenshot.js +69 -2
  40. package/dist/src/browser/screenshot.js.map +1 -1
  41. package/dist/src/browser/types.d.ts.map +1 -1
  42. package/dist/src/browser/types.js +11 -0
  43. package/dist/src/browser/types.js.map +1 -1
  44. package/dist/src/cli/action.d.ts +3 -0
  45. package/dist/src/cli/action.d.ts.map +1 -0
  46. package/dist/src/cli/action.js +142 -0
  47. package/dist/src/cli/action.js.map +1 -0
  48. package/dist/src/cli/commands.d.ts +8 -0
  49. package/dist/src/cli/commands.d.ts.map +1 -0
  50. package/dist/src/cli/commands.js +3018 -0
  51. package/dist/src/cli/commands.js.map +1 -0
  52. package/dist/src/cli/output.d.ts +11 -0
  53. package/dist/src/cli/output.d.ts.map +1 -0
  54. package/dist/src/cli/output.js +33 -0
  55. package/dist/src/cli/output.js.map +1 -0
  56. package/dist/src/cli/platform.d.ts +7 -0
  57. package/dist/src/cli/platform.d.ts.map +1 -0
  58. package/dist/src/cli/platform.js +193 -0
  59. package/dist/src/cli/platform.js.map +1 -0
  60. package/dist/src/cli/playbook.d.ts +3 -0
  61. package/dist/src/cli/playbook.d.ts.map +1 -0
  62. package/dist/src/cli/playbook.js +265 -0
  63. package/dist/src/cli/playbook.js.map +1 -0
  64. package/dist/src/cli/types.d.ts +42 -0
  65. package/dist/src/cli/types.d.ts.map +1 -0
  66. package/dist/src/cli/types.js +2 -0
  67. package/dist/src/cli/types.js.map +1 -0
  68. package/dist/src/cli/workflow.d.ts +2 -0
  69. package/dist/src/cli/workflow.d.ts.map +1 -0
  70. package/dist/src/cli/workflow.js +3 -0
  71. package/dist/src/cli/workflow.js.map +1 -0
  72. package/dist/src/cli.d.ts +7 -0
  73. package/dist/src/cli.d.ts.map +1 -0
  74. package/dist/src/cli.js +187 -0
  75. package/dist/src/cli.js.map +1 -0
  76. package/dist/src/index.d.ts +0 -1
  77. package/dist/src/index.d.ts.map +1 -1
  78. package/dist/src/index.js +0 -1
  79. package/dist/src/index.js.map +1 -1
  80. package/dist/tsconfig.tsbuildinfo +1 -1
  81. package/package.json +21 -11
  82. package/src/browser/action-builder/analyzer.ts +41 -23
  83. package/src/browser/adapters/index.ts +4 -0
  84. package/src/browser/browser.ts +2 -2
  85. package/src/browser/cdp.ts +68 -1
  86. package/src/browser/dashboard/api-types.ts +1 -1
  87. package/src/browser/dashboard/server.ts +41 -30
  88. package/src/browser/dashboard/ui.html +1412 -45
  89. package/src/browser/screenshot.ts +78 -3
  90. package/src/browser/types.ts +11 -0
  91. package/src/cli/action.ts +149 -0
  92. package/src/cli/commands.ts +2892 -0
  93. package/src/cli/output.ts +37 -0
  94. package/src/cli/platform.ts +211 -0
  95. package/src/cli/types.ts +47 -0
  96. package/src/cli.ts +208 -0
  97. package/src/index.ts +0 -1
  98. package/src/browser/workflow/builtin-handlers.ts +0 -379
  99. package/src/browser/workflow/engine.ts +0 -202
  100. package/src/browser/workflow/expression.ts +0 -107
  101. package/src/browser/workflow/index.ts +0 -5
  102. package/src/browser/workflow/store.ts +0 -87
  103. package/src/browser/workflow/types.ts +0 -62
@@ -1,87 +0,0 @@
1
- import { readFile } from 'node:fs/promises';
2
- import type { WorkflowDef, RunRecord } from './types.js';
3
- import type { ActionDef } from '../action-builder/types.js';
4
-
5
- // TODO: Upgrade to better-sqlite3 for persistence across process restarts.
6
- // Schema:
7
- // CREATE TABLE browse_runs (
8
- // id TEXT PRIMARY KEY, workflow_id TEXT, workflow_name TEXT,
9
- // status TEXT, started_at INTEGER, completed_at INTEGER,
10
- // items_processed INTEGER, items_total INTEGER, error TEXT
11
- // );
12
- // CREATE TABLE browse_sessions (
13
- // id TEXT PRIMARY KEY, platform TEXT, username TEXT,
14
- // cookies TEXT, user_agent TEXT, created_at INTEGER, last_used_at INTEGER
15
- // );
16
- const runStore = new Map<string, RunRecord>();
17
-
18
- export function clearRunStore(): void {
19
- runStore.clear();
20
- }
21
-
22
- export async function readWorkflow(filePath: string): Promise<WorkflowDef> {
23
- let raw: string;
24
- try {
25
- raw = await readFile(filePath, 'utf-8');
26
- } catch {
27
- throw new Error(`Workflow file not found: ${filePath}`);
28
- }
29
- let def: unknown;
30
- try {
31
- def = JSON.parse(raw);
32
- } catch {
33
- throw new Error(`Invalid JSON in workflow file: ${filePath}`);
34
- }
35
- if (!isWorkflowDef(def)) {
36
- const w = def as Record<string, unknown>;
37
- if (typeof w?.['id'] !== 'string') throw new Error('Workflow missing required field: id');
38
- if (typeof w?.['name'] !== 'string') throw new Error('Workflow missing required field: name');
39
- if (!Array.isArray(w?.['nodes'])) throw new Error('Workflow missing required field: nodes');
40
- throw new Error('Workflow missing required field: connections');
41
- }
42
- return def;
43
- }
44
-
45
- function validateAction(def: unknown): void {
46
- if (typeof def !== 'object' || def === null) throw new Error('Action must be a JSON object');
47
- const a = def as Record<string, unknown>;
48
- if (typeof a['id'] !== 'string') throw new Error('Action missing required field: id');
49
- if (!Array.isArray(a['steps'])) throw new Error('Action missing required field: steps');
50
- }
51
-
52
- function isWorkflowDef(def: unknown): def is WorkflowDef {
53
- if (typeof def !== 'object' || def === null) return false;
54
- const w = def as Record<string, unknown>;
55
- return (
56
- typeof w['id'] === 'string' &&
57
- typeof w['name'] === 'string' &&
58
- Array.isArray(w['nodes']) &&
59
- Array.isArray(w['connections'])
60
- );
61
- }
62
-
63
- export async function readAction(filePath: string): Promise<ActionDef> {
64
- let raw: string;
65
- try {
66
- raw = await readFile(filePath, 'utf-8');
67
- } catch {
68
- throw new Error(`Action file not found: ${filePath}`);
69
- }
70
- let def: unknown;
71
- try {
72
- def = JSON.parse(raw);
73
- } catch {
74
- throw new Error(`Invalid JSON in action file: ${filePath}`);
75
- }
76
- validateAction(def);
77
- return def as ActionDef;
78
- }
79
-
80
- export async function writeRunRecord(record: RunRecord): Promise<void> {
81
- runStore.set(record.id, { ...record });
82
- }
83
-
84
- export async function listRuns(workflowId?: string): Promise<RunRecord[]> {
85
- const all = [...runStore.values()];
86
- return workflowId ? all.filter(r => r.workflowId === workflowId) : all;
87
- }
@@ -1,62 +0,0 @@
1
- export interface WorkflowDef {
2
- id: string;
3
- name: string;
4
- description?: string;
5
- params?: Record<string, { type?: string; required?: boolean; default?: unknown; description?: string }>;
6
- nodes: NodeDef[];
7
- connections: ConnectionDef[];
8
- /** Allow $env.* expressions to access env vars that match the secret denylist. Use with caution. */
9
- allowEnvAccess?: boolean;
10
- }
11
-
12
- export interface NodeDef {
13
- id: string;
14
- type: string;
15
- name?: string;
16
- config: Record<string, unknown>;
17
- onError?: 'skip' | 'stop';
18
- timeoutMs?: number;
19
- }
20
-
21
- export interface ConnectionDef {
22
- from: string;
23
- to: string;
24
- handle?: string; // port identifier for multi-output nodes (e.g. 'true'/'false' for core.if)
25
- }
26
-
27
- export interface Item {
28
- data: Record<string, unknown>;
29
- binaryBase64?: string; // base64-encoded binary payload
30
- }
31
-
32
- export type RunStatus = 'running' | 'completed' | 'failed' | 'stopped';
33
-
34
- export interface RunRecord {
35
- id: string;
36
- workflowId: string;
37
- workflowName: string;
38
- status: RunStatus;
39
- startedAt: number;
40
- completedAt?: number;
41
- itemsProcessed: number;
42
- itemsTotal: number;
43
- error?: string;
44
- }
45
-
46
- export interface StepEvent {
47
- runId: string;
48
- workflowId: string;
49
- workflowName: string;
50
- nodeId: string;
51
- nodeName: string;
52
- eventType: 'run_started' | 'step_started' | 'step_completed' | 'step_failed' | 'run_completed' | 'run_stopped';
53
- itemIndex?: number;
54
- itemTotal?: number;
55
- durationMs?: number;
56
- error?: string;
57
- timestamp: number;
58
- /** Absolute path of the project directory that emitted this event.
59
- * Clients may subscribe to a specific project by passing `?dir=<path>`.
60
- * Events without a projectDir are delivered to all clients (backward-compatible). */
61
- projectDir?: string;
62
- }