@actiondock/core 2.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.
Files changed (43) hide show
  1. package/README.md +50 -0
  2. package/package.json +51 -0
  3. package/src/build/builder.ts +205 -0
  4. package/src/build/index.ts +2 -0
  5. package/src/build/templates.ts +59 -0
  6. package/src/doctor/doctor.ts +332 -0
  7. package/src/doctor/index.ts +2 -0
  8. package/src/doctor/types.ts +25 -0
  9. package/src/export/index.ts +2 -0
  10. package/src/export/skill.ts +349 -0
  11. package/src/export/templates.ts +258 -0
  12. package/src/filter/index.ts +1 -0
  13. package/src/filter/intent.ts +154 -0
  14. package/src/index.ts +13 -0
  15. package/src/profile/client.ts +302 -0
  16. package/src/profile/index.ts +3 -0
  17. package/src/profile/manager.ts +341 -0
  18. package/src/profile/types.ts +71 -0
  19. package/src/project/index.ts +3 -0
  20. package/src/project/init.ts +194 -0
  21. package/src/project/loader.ts +382 -0
  22. package/src/project/types.ts +62 -0
  23. package/src/registry/index.ts +2 -0
  24. package/src/registry/registry.ts +703 -0
  25. package/src/registry/types.ts +127 -0
  26. package/src/runtime/context.ts +232 -0
  27. package/src/runtime/env.ts +172 -0
  28. package/src/runtime/execution-manager.ts +74 -0
  29. package/src/runtime/index.ts +5 -0
  30. package/src/runtime/runner.ts +368 -0
  31. package/src/runtime/standalone.ts +429 -0
  32. package/src/schema/validator.ts +61 -0
  33. package/src/server/body.ts +112 -0
  34. package/src/server/index.ts +6 -0
  35. package/src/server/runtime-registry.ts +80 -0
  36. package/src/server/security.ts +115 -0
  37. package/src/server/server.ts +572 -0
  38. package/src/server/types.ts +42 -0
  39. package/src/storage/index.ts +64 -0
  40. package/src/storage/mask.ts +34 -0
  41. package/src/storage/sqlite.ts +578 -0
  42. package/src/storage/types.ts +111 -0
  43. package/src/utils/index.ts +60 -0
@@ -0,0 +1,60 @@
1
+ import { homedir } from "node:os";
2
+
3
+ /**
4
+ * Parses duration strings like "500ms", "30s", "5m", "1h", "1d" or pure numbers into milliseconds.
5
+ */
6
+ export function parseDuration(input?: string): number | undefined {
7
+ if (!input || !input.trim()) {
8
+ return undefined;
9
+ }
10
+
11
+ const str = input.trim();
12
+ if (/^\d+$/.test(str)) {
13
+ return parseInt(str, 10);
14
+ }
15
+
16
+ const match = str.match(/^(\d+(?:\.\d+)?)\s*(ms|s|m|h|d)$/i);
17
+ if (!match) {
18
+ throw new Error(
19
+ `Invalid duration format: '${input}'. Supported formats: 500ms, 30s, 5m, 1h`
20
+ );
21
+ }
22
+
23
+ const val = parseFloat(match[1]);
24
+ const unit = match[2].toLowerCase();
25
+
26
+ switch (unit) {
27
+ case "ms":
28
+ return Math.round(val);
29
+ case "s":
30
+ return Math.round(val * 1000);
31
+ case "m":
32
+ return Math.round(val * 60 * 1000);
33
+ case "h":
34
+ return Math.round(val * 60 * 60 * 1000);
35
+ case "d":
36
+ return Math.round(val * 24 * 60 * 60 * 1000);
37
+ default:
38
+ return undefined;
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Extracts a concise slug from a package or action identifier (e.g. '@scope/pkg' -> 'pkg', 'team.action' -> 'action').
44
+ */
45
+ export function getPackageSlug(id: string): string {
46
+ if (id.includes("/")) {
47
+ return id.split("/").pop()!;
48
+ }
49
+ if (id.includes(".")) {
50
+ return id.split(".").pop()!;
51
+ }
52
+ return id;
53
+ }
54
+
55
+ /**
56
+ * Resolves the root ActionDock user home directory based on customHome, ACTIONDOCK_HOME, or user homedir.
57
+ */
58
+ export function getActionDockHome(customHome?: string): string {
59
+ return customHome || process.env.ACTIONDOCK_HOME || homedir();
60
+ }