@nylorun/core 0.0.0-bootstrap → 0.2.0-beta

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 (72) hide show
  1. package/CHANGELOG.md +21 -0
  2. package/LICENSE +192 -0
  3. package/README.md +16 -0
  4. package/dist/compatibility.d.ts +3 -0
  5. package/dist/compatibility.js +3 -0
  6. package/dist/contracts.d.ts +330 -0
  7. package/dist/contracts.js +366 -0
  8. package/dist/define.d.ts +32 -0
  9. package/dist/define.js +15 -0
  10. package/dist/definition/assemble.d.ts +29 -0
  11. package/dist/definition/assemble.js +120 -0
  12. package/dist/definition/bind-agent.d.ts +8 -0
  13. package/dist/definition/bind-agent.js +62 -0
  14. package/dist/definition/bind-tool.d.ts +4 -0
  15. package/dist/definition/bind-tool.js +25 -0
  16. package/dist/definition/binding.d.ts +15 -0
  17. package/dist/definition/binding.js +9 -0
  18. package/dist/definition/bound.d.ts +34 -0
  19. package/dist/definition/bound.js +1 -0
  20. package/dist/definition/builder.d.ts +66 -0
  21. package/dist/definition/builder.js +218 -0
  22. package/dist/definition/declaration.d.ts +10 -0
  23. package/dist/definition/declaration.js +93 -0
  24. package/dist/definition/from.d.ts +13 -0
  25. package/dist/definition/from.js +294 -0
  26. package/dist/definition/helpers.d.ts +23 -0
  27. package/dist/definition/helpers.js +33 -0
  28. package/dist/definition/implementations.d.ts +16 -0
  29. package/dist/definition/implementations.js +3 -0
  30. package/dist/definition/manifest.d.ts +13 -0
  31. package/dist/definition/manifest.js +60 -0
  32. package/dist/definition/output-contract.d.ts +6 -0
  33. package/dist/definition/output-contract.js +12 -0
  34. package/dist/definition/schema-json.d.ts +3 -0
  35. package/dist/definition/schema-json.js +22 -0
  36. package/dist/definition/schema.d.ts +16 -0
  37. package/dist/definition/schema.js +284 -0
  38. package/dist/definition/skill-tools.d.ts +3 -0
  39. package/dist/definition/skill-tools.js +56 -0
  40. package/dist/definition/tool-error.d.ts +9 -0
  41. package/dist/definition/tool-error.js +20 -0
  42. package/dist/errors.d.ts +17 -0
  43. package/dist/errors.js +22 -0
  44. package/dist/index.d.ts +10 -0
  45. package/dist/index.js +1 -0
  46. package/dist/types/agent.d.ts +10 -0
  47. package/dist/types/agent.js +1 -0
  48. package/dist/types/dynamics.d.ts +53 -0
  49. package/dist/types/dynamics.js +1 -0
  50. package/dist/types/manifest.d.ts +57 -0
  51. package/dist/types/manifest.js +1 -0
  52. package/dist/types/middleware.d.ts +92 -0
  53. package/dist/types/middleware.js +1 -0
  54. package/dist/types/model.d.ts +184 -0
  55. package/dist/types/model.js +1 -0
  56. package/dist/types/observe.d.ts +180 -0
  57. package/dist/types/observe.js +1 -0
  58. package/dist/types/shared.d.ts +25 -0
  59. package/dist/types/shared.js +1 -0
  60. package/dist/types/tool.d.ts +194 -0
  61. package/dist/types/tool.js +1 -0
  62. package/dist/types/transcript.d.ts +65 -0
  63. package/dist/types/transcript.js +1 -0
  64. package/dist/utils/canonical.d.ts +1 -0
  65. package/dist/utils/canonical.js +10 -0
  66. package/dist/utils/hash.d.ts +3 -0
  67. package/dist/utils/hash.js +7 -0
  68. package/dist/utils/immutable.d.ts +6 -0
  69. package/dist/utils/immutable.js +76 -0
  70. package/package.json +57 -7
  71. package/index.js +0 -1
  72. package/publish.out +0 -0
@@ -0,0 +1,6 @@
1
+ import type { JsonObject, JsonValue } from "../types/shared.js";
2
+ export declare function assertJson(value: unknown, path?: string): asserts value is JsonValue;
3
+ export declare function copyJson<T>(value: T): T;
4
+ export declare function copyJsonObject(value: unknown, path: string): JsonObject;
5
+ export declare function deepFreeze<T>(value: T): T;
6
+ export declare function freezeGraph<T>(value: T, seen?: WeakSet<object>): T;
@@ -0,0 +1,76 @@
1
+ import { HarnessError } from "../errors.js";
2
+ export function assertJson(value, path = "value") {
3
+ assertJsonValue(value, path, new WeakSet());
4
+ }
5
+ function assertJsonValue(value, path, ancestors) {
6
+ if (value === null || typeof value === "string" || typeof value === "boolean")
7
+ return;
8
+ if (typeof value === "number" && Number.isFinite(value))
9
+ return;
10
+ if (Array.isArray(value)) {
11
+ enterJsonContainer(value, path, ancestors);
12
+ value.forEach((item, index) => assertJsonValue(item, `${path}[${index}]`, ancestors));
13
+ ancestors.delete(value);
14
+ return;
15
+ }
16
+ if (typeof value === "object") {
17
+ const prototype = Object.getPrototypeOf(value);
18
+ if (prototype !== Object.prototype && prototype !== null)
19
+ throw new HarnessError("json.invalid-data", `${path} must be plain JSON data`, {
20
+ details: { path },
21
+ });
22
+ enterJsonContainer(value, path, ancestors);
23
+ for (const [key, item] of Object.entries(value)) {
24
+ if (item === undefined)
25
+ throw new HarnessError("json.invalid-data", `${path}.${key} cannot be undefined`, {
26
+ details: { path: `${path}.${key}` },
27
+ });
28
+ assertJsonValue(item, `${path}.${key}`, ancestors);
29
+ }
30
+ ancestors.delete(value);
31
+ return;
32
+ }
33
+ throw new HarnessError("json.invalid-data", `${path} must be JSON-serializable`, {
34
+ details: { path },
35
+ });
36
+ }
37
+ function enterJsonContainer(value, path, ancestors) {
38
+ if (ancestors.has(value))
39
+ throw new HarnessError("json.invalid-data", `${path} cannot contain a cycle`, {
40
+ details: { path },
41
+ });
42
+ ancestors.add(value);
43
+ }
44
+ export function copyJson(value) {
45
+ assertJson(value);
46
+ if (Array.isArray(value))
47
+ return Object.freeze(value.map((item) => copyJson(item)));
48
+ if (value !== null && typeof value === "object") {
49
+ return Object.freeze(Object.fromEntries(Object.entries(value).map(([key, item]) => [key, copyJson(item)])));
50
+ }
51
+ return value;
52
+ }
53
+ export function copyJsonObject(value, path) {
54
+ assertJson(value, path);
55
+ if (value === null || Array.isArray(value) || typeof value !== "object")
56
+ throw new HarnessError("json.invalid-object", `${path} must be a JSON object`, {
57
+ details: { path },
58
+ });
59
+ return copyJson(value);
60
+ }
61
+ export function deepFreeze(value) {
62
+ if (value && typeof value === "object" && !Object.isFrozen(value)) {
63
+ Object.freeze(value);
64
+ for (const item of Object.values(value))
65
+ deepFreeze(item);
66
+ }
67
+ return value;
68
+ }
69
+ export function freezeGraph(value, seen = new WeakSet()) {
70
+ if (!value || typeof value !== "object" || seen.has(value))
71
+ return value;
72
+ seen.add(value);
73
+ for (const item of Object.values(value))
74
+ freezeGraph(item, seen);
75
+ return Object.freeze(value);
76
+ }
package/package.json CHANGED
@@ -1,12 +1,62 @@
1
1
  {
2
2
  "name": "@nylorun/core",
3
- "version": "0.0.0-bootstrap",
4
- "description": "Bootstrap placeholder for @nylorun/core",
5
- "main": "index.js",
3
+ "version": "0.2.0-beta",
4
+ "type": "module",
5
+ "license": "Apache-2.0",
6
+ "description": "Shared agent definitions and wire contracts",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/nylorun/harness.git",
10
+ "directory": "core"
11
+ },
12
+ "files": [
13
+ "dist",
14
+ "README.md",
15
+ "LICENSE",
16
+ "CHANGELOG.md"
17
+ ],
18
+ "publishConfig": {
19
+ "access": "public",
20
+ "provenance": true
21
+ },
22
+ "engines": {
23
+ "node": "^22.14.0 || ^24.0.0 || >=26.0.0"
24
+ },
6
25
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
26
+ "build": "npm run clean && node ../scripts/check-typescript-version.mjs && tsc -p tsconfig.json",
27
+ "clean": "node -e \"import('node:fs').then(({rmSync})=>rmSync('dist',{recursive:true,force:true}))\"",
28
+ "check": "npm run build && npm test && node scripts/check-package.mjs",
29
+ "test": "vitest run --passWithNoTests",
30
+ "prepack": "npm run build"
31
+ },
32
+ "dependencies": {
33
+ "@noble/hashes": "^1.8.0"
34
+ },
35
+ "devDependencies": {
36
+ "@types/node": "^26.5.0",
37
+ "typescript": "npm:@typescript/typescript6@^6.0.2",
38
+ "vitest": "^5.0.1"
39
+ },
40
+ "exports": {
41
+ ".": {
42
+ "types": "./dist/index.d.ts",
43
+ "import": "./dist/index.js"
44
+ },
45
+ "./define": {
46
+ "types": "./dist/define.d.ts",
47
+ "import": "./dist/define.js"
48
+ },
49
+ "./contracts": {
50
+ "types": "./dist/contracts.d.ts",
51
+ "import": "./dist/contracts.js"
52
+ },
53
+ "./compatibility": {
54
+ "types": "./dist/compatibility.d.ts",
55
+ "import": "./dist/compatibility.js"
56
+ }
57
+ },
58
+ "peerDependencies": {
59
+ "zod": "^4.6.5"
8
60
  },
9
- "keywords": [],
10
- "author": "",
11
- "license": "MIT"
61
+ "sideEffects": false
12
62
  }
package/index.js DELETED
@@ -1 +0,0 @@
1
- export {}
package/publish.out DELETED
File without changes