@fides-anima/fpp-protocol-core 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 (101) hide show
  1. package/LICENSE +95 -0
  2. package/README.md +41 -0
  3. package/SKILL.md +348 -0
  4. package/constitution.json +102 -0
  5. package/constitution.yaml +106 -0
  6. package/dist/adoption-disclosure.d.ts +35 -0
  7. package/dist/adoption-disclosure.d.ts.map +1 -0
  8. package/dist/adoption-disclosure.js +67 -0
  9. package/dist/adoption-disclosure.js.map +1 -0
  10. package/dist/adoption.d.ts +56 -0
  11. package/dist/adoption.d.ts.map +1 -0
  12. package/dist/adoption.js +97 -0
  13. package/dist/adoption.js.map +1 -0
  14. package/dist/canonical-json.d.ts +23 -0
  15. package/dist/canonical-json.d.ts.map +1 -0
  16. package/dist/canonical-json.js +60 -0
  17. package/dist/canonical-json.js.map +1 -0
  18. package/dist/capsules.d.ts +63 -0
  19. package/dist/capsules.d.ts.map +1 -0
  20. package/dist/capsules.js +94 -0
  21. package/dist/capsules.js.map +1 -0
  22. package/dist/claims.d.ts +62 -0
  23. package/dist/claims.d.ts.map +1 -0
  24. package/dist/claims.js +99 -0
  25. package/dist/claims.js.map +1 -0
  26. package/dist/digest.d.ts +38 -0
  27. package/dist/digest.d.ts.map +1 -0
  28. package/dist/digest.js +52 -0
  29. package/dist/digest.js.map +1 -0
  30. package/dist/disposition.d.ts +34 -0
  31. package/dist/disposition.d.ts.map +1 -0
  32. package/dist/disposition.js +51 -0
  33. package/dist/disposition.js.map +1 -0
  34. package/dist/emergency-override.d.ts +73 -0
  35. package/dist/emergency-override.d.ts.map +1 -0
  36. package/dist/emergency-override.js +102 -0
  37. package/dist/emergency-override.js.map +1 -0
  38. package/dist/evidence.d.ts +25 -0
  39. package/dist/evidence.d.ts.map +1 -0
  40. package/dist/evidence.js +30 -0
  41. package/dist/evidence.js.map +1 -0
  42. package/dist/freshness.d.ts +41 -0
  43. package/dist/freshness.d.ts.map +1 -0
  44. package/dist/freshness.js +66 -0
  45. package/dist/freshness.js.map +1 -0
  46. package/dist/governance.d.ts +87 -0
  47. package/dist/governance.d.ts.map +1 -0
  48. package/dist/governance.js +94 -0
  49. package/dist/governance.js.map +1 -0
  50. package/dist/identity.d.ts +43 -0
  51. package/dist/identity.d.ts.map +1 -0
  52. package/dist/identity.js +93 -0
  53. package/dist/identity.js.map +1 -0
  54. package/dist/index.d.ts +30 -0
  55. package/dist/index.d.ts.map +1 -0
  56. package/dist/index.js +30 -0
  57. package/dist/index.js.map +1 -0
  58. package/dist/mandates.d.ts +80 -0
  59. package/dist/mandates.d.ts.map +1 -0
  60. package/dist/mandates.js +127 -0
  61. package/dist/mandates.js.map +1 -0
  62. package/dist/merkle.d.ts +31 -0
  63. package/dist/merkle.d.ts.map +1 -0
  64. package/dist/merkle.js +95 -0
  65. package/dist/merkle.js.map +1 -0
  66. package/dist/quorum.d.ts +133 -0
  67. package/dist/quorum.d.ts.map +1 -0
  68. package/dist/quorum.js +128 -0
  69. package/dist/quorum.js.map +1 -0
  70. package/dist/receipts.d.ts +77 -0
  71. package/dist/receipts.d.ts.map +1 -0
  72. package/dist/receipts.js +104 -0
  73. package/dist/receipts.js.map +1 -0
  74. package/dist/steward-authorization.d.ts +200 -0
  75. package/dist/steward-authorization.d.ts.map +1 -0
  76. package/dist/steward-authorization.js +483 -0
  77. package/dist/steward-authorization.js.map +1 -0
  78. package/dist/workspace-profile.d.ts +43 -0
  79. package/dist/workspace-profile.d.ts.map +1 -0
  80. package/dist/workspace-profile.js +91 -0
  81. package/dist/workspace-profile.js.map +1 -0
  82. package/package.json +56 -0
  83. package/src/adoption-disclosure.ts +120 -0
  84. package/src/adoption.ts +152 -0
  85. package/src/canonical-json.ts +70 -0
  86. package/src/capsules.ts +161 -0
  87. package/src/claims.ts +147 -0
  88. package/src/digest.ts +63 -0
  89. package/src/disposition.ts +74 -0
  90. package/src/emergency-override.ts +168 -0
  91. package/src/evidence.ts +48 -0
  92. package/src/freshness.ts +103 -0
  93. package/src/governance.ts +152 -0
  94. package/src/identity.ts +119 -0
  95. package/src/index.ts +270 -0
  96. package/src/mandates.ts +201 -0
  97. package/src/merkle.ts +138 -0
  98. package/src/quorum.ts +193 -0
  99. package/src/receipts.ts +150 -0
  100. package/src/steward-authorization.ts +657 -0
  101. package/src/workspace-profile.ts +134 -0
@@ -0,0 +1,134 @@
1
+ /**
2
+ * Harness-neutral workspace path profiles.
3
+ *
4
+ * - `openclaw` → `<homedir>/.openclaw/workspace` (absolute OpenClaw default)
5
+ * - `generic` → `$FPP_WORKSPACE` or `~/.fpp`
6
+ * - `cursor` / `claude-code` / `codex` → `~/.fpp/<profile>`
7
+ *
8
+ * When `FPP_WORKSPACE` is set, it overrides the profile root for any profile.
9
+ *
10
+ * Legacy relative configs (e.g. `.openclaw/workspace/x`) are absolutized via
11
+ * `absolutizeWorkspacePath` so runtime never accidentally resolves against CWD.
12
+ */
13
+
14
+ import { homedir as osHomedir } from "node:os";
15
+ import { isAbsolute, join } from "node:path";
16
+
17
+ export type WorkspaceProfileId =
18
+ | "openclaw"
19
+ | "generic"
20
+ | "cursor"
21
+ | "claude-code"
22
+ | "codex";
23
+
24
+ export const DEFAULT_WORKSPACE_PROFILE: WorkspaceProfileId = "openclaw";
25
+
26
+ const HARNESS_PROFILES = new Set<string>(["cursor", "claude-code", "codex"]);
27
+
28
+ const OPENCLAW_RELATIVE_PREFIX = ".openclaw/workspace";
29
+
30
+ export type ResolveWorkspaceOptions = {
31
+ profile?: WorkspaceProfileId | string | undefined;
32
+ env?: NodeJS.ProcessEnv | undefined;
33
+ homedir?: (() => string) | undefined;
34
+ };
35
+
36
+ export type AbsolutizeWorkspaceOptions = ResolveWorkspaceOptions & {
37
+ /** Optional detected OpenClaw workspace absolute path when FPP_WORKSPACE is unset. */
38
+ openclawWorkspace?: string | undefined;
39
+ };
40
+
41
+ function normalizeRoot(root: string): string {
42
+ return root.replace(/\\/g, "/").replace(/\/+$/, "");
43
+ }
44
+
45
+ function isAbsolutePath(p: string): boolean {
46
+ const n = p.replace(/\\/g, "/");
47
+ return isAbsolute(n) || /^[A-Za-z]:\//.test(n);
48
+ }
49
+
50
+ /**
51
+ * Resolve the workspace root directory for the active profile.
52
+ */
53
+ export function resolveWorkspaceRoot(
54
+ options: ResolveWorkspaceOptions = {},
55
+ ): string {
56
+ const env = options.env ?? process.env;
57
+ const override = env.FPP_WORKSPACE?.trim();
58
+ if (override) {
59
+ return normalizeRoot(override);
60
+ }
61
+
62
+ const profile = (options.profile ?? DEFAULT_WORKSPACE_PROFILE) as string;
63
+ const home = () => (options.homedir ?? osHomedir)();
64
+
65
+ if (profile === "generic") {
66
+ return normalizeRoot(join(home(), ".fpp"));
67
+ }
68
+
69
+ if (HARNESS_PROFILES.has(profile)) {
70
+ return normalizeRoot(join(home(), ".fpp", profile));
71
+ }
72
+
73
+ // openclaw (default) and unknown profiles use absolute OpenClaw layout
74
+ return normalizeRoot(join(home(), ".openclaw", "workspace"));
75
+ }
76
+
77
+ /**
78
+ * Join a filename under the resolved workspace root using forward slashes
79
+ * (stable across hosts for config defaults and docs).
80
+ */
81
+ export function workspaceFile(
82
+ filename: string,
83
+ options: ResolveWorkspaceOptions = {},
84
+ ): string {
85
+ const root = resolveWorkspaceRoot(options);
86
+ const name = filename.replace(/^\/+/, "");
87
+ return `${root}/${name}`;
88
+ }
89
+
90
+ /**
91
+ * Resolve a possibly-relative workspace path to an absolute path.
92
+ *
93
+ * Absolute inputs are returned normalized. Relative inputs resolve against:
94
+ * `FPP_WORKSPACE` → `openclawWorkspace` (if provided) → `homedir()`
95
+ *
96
+ * Legacy `.openclaw/workspace/...` strings map onto the workspace root + remainder
97
+ * when the base is an explicit workspace override (FPP_WORKSPACE / openclawWorkspace).
98
+ */
99
+ export function absolutizeWorkspacePath(
100
+ inputPath: string,
101
+ options: AbsolutizeWorkspaceOptions = {},
102
+ ): string {
103
+ const normalized = inputPath.replace(/\\/g, "/");
104
+ if (isAbsolutePath(normalized)) {
105
+ return normalizeRoot(normalized);
106
+ }
107
+
108
+ const env = options.env ?? process.env;
109
+ const fppWs = env.FPP_WORKSPACE?.trim();
110
+ const detected = options.openclawWorkspace?.trim();
111
+ const home = (options.homedir ?? osHomedir)();
112
+
113
+ const stripOpenclawPrefix = (base: string): string => {
114
+ const root = normalizeRoot(base);
115
+ if (
116
+ normalized === OPENCLAW_RELATIVE_PREFIX ||
117
+ normalized.startsWith(`${OPENCLAW_RELATIVE_PREFIX}/`)
118
+ ) {
119
+ const rest = normalized
120
+ .slice(OPENCLAW_RELATIVE_PREFIX.length)
121
+ .replace(/^\//, "");
122
+ return rest ? `${root}/${rest}` : root;
123
+ }
124
+ return normalizeRoot(join(root, normalized));
125
+ };
126
+
127
+ if (fppWs) {
128
+ return stripOpenclawPrefix(fppWs);
129
+ }
130
+ if (detected) {
131
+ return stripOpenclawPrefix(detected);
132
+ }
133
+ return normalizeRoot(join(home, normalized));
134
+ }