@you-agent-factory/factory-graph 0.0.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.
@@ -0,0 +1,29 @@
1
+ import type { FactoryDefinition } from "@you-agent-factory/client";
2
+ import type { FactoryActivityProjection, FactoryLoadProjection, FactoryTopologyProjection } from "@you-agent-factory/factory-replay";
3
+ /** Runtime information consumed by the semantic Factory graph at one selected tick. */
4
+ export interface FactoryGraphRuntimeProjection {
5
+ activity: FactoryActivityProjection;
6
+ load: FactoryLoadProjection;
7
+ topology: FactoryTopologyProjection;
8
+ }
9
+ /** Host-owned selection behavior for a read-only graph. */
10
+ export interface FactoryGraphObserveControls {
11
+ onSelectNode?: (nodeId: string) => void;
12
+ selectedNodeId?: string;
13
+ }
14
+ /**
15
+ * Lossless input to a Factory graph renderer.
16
+ *
17
+ * Hosts retain ownership of event streaming, timeline selection, persistence,
18
+ * and editing. The graph receives the complete Factory alongside the selected
19
+ * runtime projection, so semantic node renderers never need a reduced
20
+ * topology-only substitute.
21
+ */
22
+ export interface FactoryGraphSource {
23
+ factory: Readonly<FactoryDefinition>;
24
+ runtime: FactoryGraphRuntimeProjection;
25
+ selectedTick: number;
26
+ }
27
+ export declare function isFactoryGraphSource(value: unknown): value is FactoryGraphSource;
28
+ /** Validate the stable graph boundary without cloning or reducing its inputs. */
29
+ export declare function createFactoryGraphSource(source: FactoryGraphSource): FactoryGraphSource;
package/dist/source.js ADDED
@@ -0,0 +1,18 @@
1
+ export function isFactoryGraphSource(value) {
2
+ if (!value || typeof value !== "object")
3
+ return false;
4
+ const source = value;
5
+ const selectedTick = source.selectedTick;
6
+ return (source.factory !== undefined &&
7
+ source.runtime !== undefined &&
8
+ typeof selectedTick === "number" &&
9
+ Number.isSafeInteger(selectedTick) &&
10
+ selectedTick >= 0);
11
+ }
12
+ /** Validate the stable graph boundary without cloning or reducing its inputs. */
13
+ export function createFactoryGraphSource(source) {
14
+ if (!isFactoryGraphSource(source)) {
15
+ throw new TypeError("Factory graph source requires a Factory, runtime projection, and non-negative selected tick.");
16
+ }
17
+ return source;
18
+ }
@@ -0,0 +1,8 @@
1
+ import type { GraphSemanticIconKind } from "./semantic-icon.js";
2
+ export declare const FACTORY_GRAPH_WORK_STATE_TYPES: readonly ["INITIAL", "PROCESSING", "TERMINAL", "FAILED"];
3
+ export type FactoryGraphWorkStateType = (typeof FACTORY_GRAPH_WORK_STATE_TYPES)[number];
4
+ export declare const WORK_STATE_PHASE_LEGEND_ORDER: readonly ["INITIAL", "PROCESSING", "TERMINAL", "FAILED"];
5
+ export declare function workStatePhaseSwatchClassName(_workStateType: FactoryGraphWorkStateType): string;
6
+ export declare function workStatePhaseSurfaceClassName(_workStateType: FactoryGraphWorkStateType | undefined): string;
7
+ export declare function workStatePhaseSemanticIconKind(workStateType: FactoryGraphWorkStateType | undefined): GraphSemanticIconKind;
8
+ export declare function workStatePhaseSemanticIconClassName(workStateType: FactoryGraphWorkStateType | undefined): string;
@@ -0,0 +1,40 @@
1
+ import { factoryGraphNodeSurfaceClassName } from "./semantic-node-style.js";
2
+ export const FACTORY_GRAPH_WORK_STATE_TYPES = [
3
+ "INITIAL",
4
+ "PROCESSING",
5
+ "TERMINAL",
6
+ "FAILED",
7
+ ];
8
+ export const WORK_STATE_PHASE_LEGEND_ORDER = [
9
+ "INITIAL",
10
+ "PROCESSING",
11
+ "TERMINAL",
12
+ "FAILED",
13
+ ];
14
+ const WORK_STATE_SURFACE = factoryGraphNodeSurfaceClassName("workState");
15
+ const ICON_KIND_BY_PHASE = {
16
+ INITIAL: "queue",
17
+ PROCESSING: "processing",
18
+ TERMINAL: "terminal",
19
+ FAILED: "failed",
20
+ };
21
+ const ICON_CLASS_BY_PHASE = {
22
+ INITIAL: "text-info",
23
+ PROCESSING: "text-warning",
24
+ TERMINAL: "text-success",
25
+ FAILED: "text-error",
26
+ };
27
+ export function workStatePhaseSwatchClassName(_workStateType) {
28
+ return WORK_STATE_SURFACE;
29
+ }
30
+ export function workStatePhaseSurfaceClassName(_workStateType) {
31
+ return WORK_STATE_SURFACE;
32
+ }
33
+ export function workStatePhaseSemanticIconKind(workStateType) {
34
+ return workStateType ? ICON_KIND_BY_PHASE[workStateType] : "queue";
35
+ }
36
+ export function workStatePhaseSemanticIconClassName(workStateType) {
37
+ return workStateType
38
+ ? ICON_CLASS_BY_PHASE[workStateType]
39
+ : "text-on-surface-variant";
40
+ }
package/package.json ADDED
@@ -0,0 +1,54 @@
1
+ {
2
+ "name": "@you-agent-factory/factory-graph",
3
+ "version": "0.0.0",
4
+ "description": "Lossless Factory graph source contracts shared by semantic graph renderers.",
5
+ "license": "MIT",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/portpowered/you-agent-factory.git",
9
+ "directory": "ui/packages/factory-graph"
10
+ },
11
+ "publishConfig": {
12
+ "access": "public"
13
+ },
14
+ "files": [
15
+ "dist",
16
+ "LICENSE.md",
17
+ "README.md"
18
+ ],
19
+ "type": "module",
20
+ "sideEffects": false,
21
+ "exports": {
22
+ ".": {
23
+ "types": "./dist/index.d.ts",
24
+ "import": "./dist/index.js",
25
+ "default": "./dist/index.js"
26
+ }
27
+ },
28
+ "scripts": {
29
+ "build": "bun run prepare:dependencies && node scripts/build-package.mjs",
30
+ "check:pack": "node scripts/verify-package-pack.mjs",
31
+ "check:package-boundary": "node scripts/check-package-boundary.mjs",
32
+ "prepare:dependencies": "bun run --cwd ../client build && bun run --cwd ../components build && bun run --cwd ../factory-replay build",
33
+ "test": "bun run prepare:dependencies && vitest run --config vitest.config.ts",
34
+ "typecheck": "bun run prepare:dependencies && tsc -p tsconfig.json --noEmit --pretty false",
35
+ "verify": "bun run typecheck && bun run test && bun run build && bun run check:package-boundary && bun run check:pack"
36
+ },
37
+ "peerDependencies": {
38
+ "@you-agent-factory/client": "0.0.0",
39
+ "@you-agent-factory/components": "0.0.0",
40
+ "@you-agent-factory/factory-replay": "0.0.0",
41
+ "@xyflow/react": "^12.10.2",
42
+ "react": "^19.0.0"
43
+ },
44
+ "devDependencies": {
45
+ "@you-agent-factory/client": "workspace:*",
46
+ "@you-agent-factory/components": "workspace:*",
47
+ "@you-agent-factory/factory-replay": "workspace:*",
48
+ "@types/react": "^19.2.2",
49
+ "@xyflow/react": "^12.10.2",
50
+ "react": "^19.0.0",
51
+ "typescript": "~5.9.3",
52
+ "vitest": "4.1.3"
53
+ }
54
+ }