@graphorin/core 0.5.0 → 0.6.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 (92) hide show
  1. package/CHANGELOG.md +98 -1
  2. package/README.md +6 -6
  3. package/dist/channels/channels.d.ts +3 -3
  4. package/dist/channels/channels.d.ts.map +1 -1
  5. package/dist/channels/channels.js.map +1 -1
  6. package/dist/channels/directive.d.ts +8 -3
  7. package/dist/channels/directive.d.ts.map +1 -1
  8. package/dist/channels/directive.js +8 -3
  9. package/dist/channels/directive.js.map +1 -1
  10. package/dist/channels/dispatch.d.ts +9 -1
  11. package/dist/channels/dispatch.d.ts.map +1 -1
  12. package/dist/channels/dispatch.js +9 -1
  13. package/dist/channels/dispatch.js.map +1 -1
  14. package/dist/channels/durable.d.ts +94 -0
  15. package/dist/channels/durable.d.ts.map +1 -0
  16. package/dist/channels/durable.js +106 -0
  17. package/dist/channels/durable.js.map +1 -0
  18. package/dist/channels/index.d.ts +2 -1
  19. package/dist/channels/index.js +2 -1
  20. package/dist/channels/pause.d.ts +4 -4
  21. package/dist/channels/pause.d.ts.map +1 -1
  22. package/dist/channels/pause.js +4 -4
  23. package/dist/channels/pause.js.map +1 -1
  24. package/dist/contracts/auth-token-store.d.ts +2 -2
  25. package/dist/contracts/checkpoint-store.d.ts +41 -5
  26. package/dist/contracts/checkpoint-store.d.ts.map +1 -1
  27. package/dist/contracts/checkpoint-store.js +25 -0
  28. package/dist/contracts/checkpoint-store.js.map +1 -0
  29. package/dist/contracts/embedder.d.ts +1 -1
  30. package/dist/contracts/index.d.ts +4 -4
  31. package/dist/contracts/index.js +2 -1
  32. package/dist/contracts/local-provider-trust.d.ts +4 -4
  33. package/dist/contracts/logger.d.ts +1 -1
  34. package/dist/contracts/logger.js.map +1 -1
  35. package/dist/contracts/memory-store.d.ts +1 -1
  36. package/dist/contracts/memory-store.d.ts.map +1 -1
  37. package/dist/contracts/oauth-server-store.d.ts +1 -1
  38. package/dist/contracts/preferred-model.d.ts +4 -4
  39. package/dist/contracts/preferred-model.js.map +1 -1
  40. package/dist/contracts/provider.d.ts +31 -5
  41. package/dist/contracts/provider.d.ts.map +1 -1
  42. package/dist/contracts/reasoning-retention.d.ts +3 -3
  43. package/dist/contracts/redaction-validator.d.ts +1 -1
  44. package/dist/contracts/sandbox.d.ts +1 -1
  45. package/dist/contracts/secret-value.d.ts +1 -1
  46. package/dist/contracts/secret-value.js.map +1 -1
  47. package/dist/contracts/secrets-store.d.ts +3 -3
  48. package/dist/contracts/session-store.d.ts +9 -7
  49. package/dist/contracts/session-store.d.ts.map +1 -1
  50. package/dist/contracts/tool.d.ts +20 -7
  51. package/dist/contracts/tool.d.ts.map +1 -1
  52. package/dist/contracts/tracer.d.ts +1 -1
  53. package/dist/contracts/tracer.d.ts.map +1 -1
  54. package/dist/contracts/tracer.js.map +1 -1
  55. package/dist/index.d.ts +11 -10
  56. package/dist/index.d.ts.map +1 -1
  57. package/dist/index.js +5 -3
  58. package/dist/index.js.map +1 -1
  59. package/dist/types/agent-event.d.ts +24 -10
  60. package/dist/types/agent-event.d.ts.map +1 -1
  61. package/dist/types/handoff.d.ts +9 -9
  62. package/dist/types/index.d.ts +5 -5
  63. package/dist/types/memory.d.ts +66 -23
  64. package/dist/types/memory.d.ts.map +1 -1
  65. package/dist/types/message.d.ts +2 -2
  66. package/dist/types/message.d.ts.map +1 -1
  67. package/dist/types/run.d.ts +57 -4
  68. package/dist/types/run.d.ts.map +1 -1
  69. package/dist/types/run.js +1 -1
  70. package/dist/types/run.js.map +1 -1
  71. package/dist/types/sensitivity.d.ts +3 -3
  72. package/dist/types/sensitivity.js.map +1 -1
  73. package/dist/types/stop-condition.d.ts +1 -1
  74. package/dist/types/stop-condition.js.map +1 -1
  75. package/dist/types/tool.d.ts +49 -24
  76. package/dist/types/tool.d.ts.map +1 -1
  77. package/dist/types/usage.d.ts +25 -1
  78. package/dist/types/usage.d.ts.map +1 -1
  79. package/dist/types/usage.js.map +1 -1
  80. package/dist/types/workflow-event.d.ts +8 -1
  81. package/dist/types/workflow-event.d.ts.map +1 -1
  82. package/dist/utils/assert-never.d.ts +1 -1
  83. package/dist/utils/assert-never.js +1 -1
  84. package/dist/utils/assert-never.js.map +1 -1
  85. package/dist/utils/hash.d.ts +9 -7
  86. package/dist/utils/hash.d.ts.map +1 -1
  87. package/dist/utils/hash.js +9 -7
  88. package/dist/utils/hash.js.map +1 -1
  89. package/dist/utils/validation.d.ts +1 -1
  90. package/dist/utils/validation.js +1 -1
  91. package/dist/utils/validation.js.map +1 -1
  92. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"tool.d.ts","names":[],"sources":["../../src/types/tool.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAWA;AAsBA;AAyBA;AAmBA;AAuBA;AAUA;AAeY,KAlHA,aAAA,GAkHU,MAAA,GAAA,WAAA,GAAA,UAAA,GAAA,QAAA;AAmBtB;AAgBA;;;;;AAgCA;AA+BA;AAmBA;AAiBA;;;;;AASA;AAcA;;;;;KAzPY,eAAA;;;;;;;;;;;;;;;;;;;KAyBA,eAAA;;;;;;;;;;;;;;;;;;KAmBA,yBAAA;;;;;;;;;;;;;;;;;KAuBA,kBAAA;;;;;;;;;KAUA,cAAA;;;;;;;;KAeA,UAAA;;;;;;;;;;;;;;;;;;;;;;;;KAmBA,YAAA;;;;;;;;;iBAGiC;;;;;;;;UAa5B;;;mBAGE;;;;;;mCAAO,cAAA;;;;;;;;;;0BAgBA;;;;;;;;;;;;UAaT,YAAA;;;;;;;;;;;;;;;;;;;;;;gCAsBe;;;;;;;;KASpB,aAAA;;;;;;;UAmBK,SAAA;;;iBAGA;;;;;;;;;;;;;KAcL,iCAAiC,WAAW,WAAW;;;;;;;;UASlD,YAAA;;;;;;;;;;;;;UAcA;iBACA;oBACG,YAAY"}
1
+ {"version":3,"file":"tool.d.ts","names":[],"sources":["../../src/types/tool.ts"],"sourcesContent":[],"mappings":";;;;;;;;AAWA;AAsBA;AAyBA;AAmBA;AAuBA;AAUA;AAeY,KAlHA,aAAA,GAkHU,MAAA,GAAA,WAAA,GAAA,UAAA,GAAA,QAAA;AAmBtB;AAgBA;;;;;AAgCA;AA+BA;AA8BA;AAQA;AAyBA;;;;;AASA;AAcA;;;;AAE+B,KAtRnB,eAAA,GAsRmB,MAAA,GAAA,0BAAA,GAAA,cAAA,GAAA,SAAA,GAAA,WAAA;;;;;;;;;;;;;;;;;;;KA7PnB,eAAA;;;;;;;;;;;;;;;;;;KAmBA,yBAAA;;;;;;;;;;;;;;;;;KAuBA,kBAAA;;;;;;;;;KAUA,cAAA;;;;;;;;KAeA,UAAA;;;;;;;;;;;;;;;;;;;;;;;;KAmBA,YAAA;;;;;;;;;iBAGiC;;;;;;;;UAa5B;;;mBAGE;;;;;;mCAAO,cAAA;;;;;;;;;;0BAgBA;;;;;;;;;;;;UAaT,YAAA;;;;;;;;;;;;;;;;;;;;;;gCAsBe;;;;;;;;KASpB,aAAA;;;;;;;;;;;;;;;;;KA8BA,YAAA;;;;;;;UAQK,SAAA;;;iBAGA;;;;;;;;;;;;;0BAaS;;;;;;;;KASd,iCAAiC,WAAW,WAAW;;;;;;;;UASlD,YAAA;;;;;;;;;;;;;UAcA;iBACA;oBACG,YAAY"}
@@ -3,15 +3,37 @@
3
3
  * Token / cost metrics for a single LLM call.
4
4
  *
5
5
  * `cost` is optional because the framework cannot compute it without a
6
- * pricing snapshot providers/middleware fill it in (e.g. through the
6
+ * pricing snapshot - providers/middleware fill it in (e.g. through the
7
7
  * separate `@graphorin/pricing` package) when the snapshot is available.
8
8
  *
9
9
  * @stable
10
10
  */
11
11
  interface Usage {
12
+ /**
13
+ * Total input tokens for the call, INCLUDING any prompt-cache reads and
14
+ * writes (`cachedReadTokens` / `cacheWriteTokens` are informational
15
+ * subsets, not additions). This matches the context size the model saw.
16
+ */
12
17
  promptTokens: number;
13
18
  completionTokens: number;
19
+ /**
20
+ * Reasoning tokens billed IN ADDITION to `completionTokens` (exclusive;
21
+ * adapters that receive an inclusive total split it so the sum stays
22
+ * exact). Cost formulas may add this to the output leg without
23
+ * double-counting.
24
+ */
14
25
  reasoningTokens?: number;
26
+ /**
27
+ * Prompt tokens served from the provider's prompt cache (a subset of
28
+ * `promptTokens`), billed at the discounted cache-read rate.
29
+ */
30
+ cachedReadTokens?: number;
31
+ /**
32
+ * Prompt tokens written to the provider's prompt cache this call (a
33
+ * subset of `promptTokens`), billed at the cache-write premium where the
34
+ * provider charges one (Anthropic does; OpenAI does not report writes).
35
+ */
36
+ cacheWriteTokens?: number;
15
37
  totalTokens: number;
16
38
  cost?: Cost;
17
39
  }
@@ -38,6 +60,8 @@ interface ModelUsage {
38
60
  promptTokens: number;
39
61
  completionTokens: number;
40
62
  reasoningTokens?: number;
63
+ cachedReadTokens?: number;
64
+ cacheWriteTokens?: number;
41
65
  totalTokens: number;
42
66
  cost?: Cost;
43
67
  callCount: number;
@@ -1 +1 @@
1
- {"version":3,"file":"usage.d.ts","names":[],"sources":["../../src/types/usage.ts"],"sourcesContent":[],"mappings":";;AASA;AAcA;AAaA;AAkBA;;;;;AAWc,UAxDG,KAAA,CAwDH;EAAa,YAAA,EAAA,MAAA;EAQV,gBAAa,EAAA,MAAA;EAUd,eAAS,CAAA,EAAA,MAAA;;SArEhB;;;;;;;;UASQ,IAAA;;;;;;;;;;;;UAaA,UAAA;;;;;;SAMR;;;;;;;;;;;UAYQ,gBAAA;;kBAEC;;oBAEE,oBAAoB;;8BAGV;;;;cAIhB;;;;;;;UAQG,aAAA;kBACC;6BACW;;;;;;;iBAQb,SAAA,CAAA,GAAa"}
1
+ {"version":3,"file":"usage.d.ts","names":[],"sources":["../../src/types/usage.ts"],"sourcesContent":[],"mappings":";;AASA;AAoCA;AAaA;AAoBA;;;;;AAWc,UAhFG,KAAA,CAgFH;EAAa;AAQ3B;AAUA;;;;;;;;;;;;;;;;;;;;;;;;SAvES;;;;;;;;UASQ,IAAA;;;;;;;;;;;;UAaA,UAAA;;;;;;;;SAQR;;;;;;;;;;;UAYQ,gBAAA;;kBAEC;;oBAEE,oBAAoB;;8BAGV;;;;cAIhB;;;;;;;UAQG,aAAA;kBACC;6BACW;;;;;;;iBAQb,SAAA,CAAA,GAAa"}
@@ -1 +1 @@
1
- {"version":3,"file":"usage.js","names":[],"sources":["../../src/types/usage.ts"],"sourcesContent":["/**\n * Token / cost metrics for a single LLM call.\n *\n * `cost` is optional because the framework cannot compute it without a\n * pricing snapshot providers/middleware fill it in (e.g. through the\n * separate `@graphorin/pricing` package) when the snapshot is available.\n *\n * @stable\n */\nexport interface Usage {\n promptTokens: number;\n completionTokens: number;\n reasoningTokens?: number;\n totalTokens: number;\n cost?: Cost;\n}\n\n/**\n * Money figure attached to a `Usage`. Always carries a 3-letter currency\n * code so that consumers can perform aggregation safely.\n *\n * @stable\n */\nexport interface Cost {\n /** Amount in the smallest fractional unit of the declared currency. */\n amount: number;\n /** ISO-4217 currency code; default `'USD'`. */\n currency: string;\n}\n\n/**\n * Per-model breakdown used by aggregators (e.g. `CostTracker` in\n * `@graphorin/observability`).\n *\n * @stable\n */\nexport interface ModelUsage {\n modelId: string;\n promptTokens: number;\n completionTokens: number;\n reasoningTokens?: number;\n totalTokens: number;\n cost?: Cost;\n callCount: number;\n}\n\n/**\n * A live accumulator of token / cost figures. Implementations live in\n * `@graphorin/observability`. The contract sits here so every package\n * (agent, workflow, server, …) can type a parameter as `UsageAccumulator`\n * without taking an observability dependency.\n *\n * @stable\n */\nexport interface UsageAccumulator {\n /** Current rolled-up totals across every model that has been added. */\n readonly total: Usage;\n /** Per-model breakdown; preserves call counts for observability. */\n readonly byModel: ReadonlyMap<string, ModelUsage>;\n\n /** Add a single LLM-call usage record under the given model id. */\n add(modelId: string, usage: Usage): void;\n /** Reset the accumulator to a zeroed state. */\n reset(): void;\n /** Render an immutable snapshot suitable for serialization / span attrs. */\n snapshot(): UsageSnapshot;\n}\n\n/**\n * Immutable, JSON-serializable snapshot of a `UsageAccumulator`.\n *\n * @stable\n */\nexport interface UsageSnapshot {\n readonly total: Usage;\n readonly byModel: readonly ModelUsage[];\n}\n\n/**\n * Returns a fresh, zeroed `Usage` value.\n *\n * @stable\n */\nexport function zeroUsage(): Usage {\n return { promptTokens: 0, completionTokens: 0, totalTokens: 0 };\n}\n"],"mappings":";;;;;;AAmFA,SAAgB,YAAmB;AACjC,QAAO;EAAE,cAAc;EAAG,kBAAkB;EAAG,aAAa;EAAG"}
1
+ {"version":3,"file":"usage.js","names":[],"sources":["../../src/types/usage.ts"],"sourcesContent":["/**\n * Token / cost metrics for a single LLM call.\n *\n * `cost` is optional because the framework cannot compute it without a\n * pricing snapshot - providers/middleware fill it in (e.g. through the\n * separate `@graphorin/pricing` package) when the snapshot is available.\n *\n * @stable\n */\nexport interface Usage {\n /**\n * Total input tokens for the call, INCLUDING any prompt-cache reads and\n * writes (`cachedReadTokens` / `cacheWriteTokens` are informational\n * subsets, not additions). This matches the context size the model saw.\n */\n promptTokens: number;\n completionTokens: number;\n /**\n * Reasoning tokens billed IN ADDITION to `completionTokens` (exclusive;\n * adapters that receive an inclusive total split it so the sum stays\n * exact). Cost formulas may add this to the output leg without\n * double-counting.\n */\n reasoningTokens?: number;\n /**\n * Prompt tokens served from the provider's prompt cache (a subset of\n * `promptTokens`), billed at the discounted cache-read rate.\n */\n cachedReadTokens?: number;\n /**\n * Prompt tokens written to the provider's prompt cache this call (a\n * subset of `promptTokens`), billed at the cache-write premium where the\n * provider charges one (Anthropic does; OpenAI does not report writes).\n */\n cacheWriteTokens?: number;\n totalTokens: number;\n cost?: Cost;\n}\n\n/**\n * Money figure attached to a `Usage`. Always carries a 3-letter currency\n * code so that consumers can perform aggregation safely.\n *\n * @stable\n */\nexport interface Cost {\n /** Amount in the smallest fractional unit of the declared currency. */\n amount: number;\n /** ISO-4217 currency code; default `'USD'`. */\n currency: string;\n}\n\n/**\n * Per-model breakdown used by aggregators (e.g. `CostTracker` in\n * `@graphorin/observability`).\n *\n * @stable\n */\nexport interface ModelUsage {\n modelId: string;\n promptTokens: number;\n completionTokens: number;\n reasoningTokens?: number;\n cachedReadTokens?: number;\n cacheWriteTokens?: number;\n totalTokens: number;\n cost?: Cost;\n callCount: number;\n}\n\n/**\n * A live accumulator of token / cost figures. Implementations live in\n * `@graphorin/observability`. The contract sits here so every package\n * (agent, workflow, server, …) can type a parameter as `UsageAccumulator`\n * without taking an observability dependency.\n *\n * @stable\n */\nexport interface UsageAccumulator {\n /** Current rolled-up totals across every model that has been added. */\n readonly total: Usage;\n /** Per-model breakdown; preserves call counts for observability. */\n readonly byModel: ReadonlyMap<string, ModelUsage>;\n\n /** Add a single LLM-call usage record under the given model id. */\n add(modelId: string, usage: Usage): void;\n /** Reset the accumulator to a zeroed state. */\n reset(): void;\n /** Render an immutable snapshot suitable for serialization / span attrs. */\n snapshot(): UsageSnapshot;\n}\n\n/**\n * Immutable, JSON-serializable snapshot of a `UsageAccumulator`.\n *\n * @stable\n */\nexport interface UsageSnapshot {\n readonly total: Usage;\n readonly byModel: readonly ModelUsage[];\n}\n\n/**\n * Returns a fresh, zeroed `Usage` value.\n *\n * @stable\n */\nexport function zeroUsage(): Usage {\n return { promptTokens: 0, completionTokens: 0, totalTokens: 0 };\n}\n"],"mappings":";;;;;;AA2GA,SAAgB,YAAmB;AACjC,QAAO;EAAE,cAAc;EAAG,kBAAkB;EAAG,aAAa;EAAG"}
@@ -49,6 +49,13 @@ interface WorkflowChannelUpdateEvent<TState = unknown> {
49
49
  readonly stepNumber: number;
50
50
  readonly channel: keyof TState & string;
51
51
  readonly version: number;
52
+ /**
53
+ * The merged value, carried ONLY for `ephemeral` channels
54
+ * (workflow-07): their values are wiped from state before the next
55
+ * planning round, so this event is the one place a consumer can
56
+ * observe them. Persistent channels omit it - read the state instead.
57
+ */
58
+ readonly value?: unknown;
52
59
  }
53
60
  /** @stable */
54
61
  interface WorkflowCheckpointWrittenEvent {
@@ -57,7 +64,7 @@ interface WorkflowCheckpointWrittenEvent {
57
64
  readonly stepNumber: number;
58
65
  }
59
66
  /**
60
- * Workflow paused for HITL approvals or programmatic `pause(value)`
67
+ * Workflow paused - for HITL approvals or programmatic `pause(value)`
61
68
  * calls. Carries the value passed to `pause(...)` so the caller can
62
69
  * choose how to surface the prompt to the user.
63
70
  *
@@ -1 +1 @@
1
- {"version":3,"file":"workflow-event.d.ts","names":[],"sources":["../../src/types/workflow-event.ts"],"sourcesContent":[],"mappings":";;AASA;;;;;;;;AAM+B,KANnB,aAMmB,CAAA,SAAA,OAAA,CAAA,GAL3B,kBAK2B,GAJ3B,sBAI2B,CAJJ,MAII,CAAA,GAH3B,oBAG2B,CAHN,MAGM,CAAA,GAF3B,sBAE2B,GAD3B,oBAC2B,GAA3B,0BAA2B,CAAA,MAAA,CAAA,GAC3B,8BAD2B,GAE3B,sBAF2B,CAEJ,MAFI,CAAA,GAG3B,oBAH2B,CAGN,MAHM,CAAA,GAI3B,gBAJ2B,CAIV,MAJU,CAAA,GAK3B,kBAL2B,GAM3B,mBAN2B;;AAC3B,UAQa,kBAAA,CARb;EACuB,SAAA,IAAA,EAAA,gBAAA;EAAvB,SAAA,QAAA,EAAA,MAAA;EACqB,SAAA,UAAA,EAAA,MAAA;;;AACrB,UAYa,sBAZb,CAAA,SAAA,OAAA,CAAA,CAAA;EACA,SAAA,IAAA,EAAA,qBAAA;EACA,SAAA,UAAA,EAAA,MAAA;EAAmB,SAAA,KAAA,EAaL,MAbK;AAGvB;AAOA;AAOiB,UAAA,oBAAoB,CAAA,SAGnB,OAAM,CAAA,CAAA;EAIP,SAAA,IAAA,EAAA,mBAAsB;EAQtB,SAAA,UAAA,EAAA,MAAoB;EAUpB,SAAA,KAAA,EAtBC,MAsBD;AAQjB;AAaA;AASiB,UAhDA,sBAAA,CAgDoB;EAQpB,SAAA,IAAA,EAAA,qBAAgB;EAOhB,SAAA,UAAA,EAAkB,MAAA;EAYlB,SAAA,MAAA,EAAA,MAAmB;;;;UAnEnB,oBAAA;;;;;;;;;UAUA;;;0BAGS;;;;UA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AKD;;;;kBAIC;;;UAID;;;kBAGC;;;UAID,kBAAA;;;;;;;;;;;;;;UAYA,mBAAA"}
@@ -3,7 +3,7 @@
3
3
  * Exhaustiveness helper. Place at the end of a `switch (...)` over a
4
4
  * discriminated union: TypeScript narrows the operand to `never` if
5
5
  * every variant is handled. Adding a new variant later turns the call
6
- * site into a compile error the regression net for our event unions.
6
+ * site into a compile error - the regression net for our event unions.
7
7
  *
8
8
  * @example
9
9
  * ```ts
@@ -3,7 +3,7 @@
3
3
  * Exhaustiveness helper. Place at the end of a `switch (...)` over a
4
4
  * discriminated union: TypeScript narrows the operand to `never` if
5
5
  * every variant is handled. Adding a new variant later turns the call
6
- * site into a compile error the regression net for our event unions.
6
+ * site into a compile error - the regression net for our event unions.
7
7
  *
8
8
  * @example
9
9
  * ```ts
@@ -1 +1 @@
1
- {"version":3,"file":"assert-never.js","names":[],"sources":["../../src/utils/assert-never.ts"],"sourcesContent":["/**\n * Exhaustiveness helper. Place at the end of a `switch (...)` over a\n * discriminated union: TypeScript narrows the operand to `never` if\n * every variant is handled. Adding a new variant later turns the call\n * site into a compile error the regression net for our event unions.\n *\n * @example\n * ```ts\n * function describe(event: AgentEvent): string {\n * switch (event.type) {\n * case 'agent.start': return 'started';\n * case 'agent.end': return 'ended';\n * // ... every other variant ...\n * default:\n * return assertNever(event, 'Unhandled AgentEvent variant');\n * }\n * }\n * ```\n *\n * @stable\n */\nexport function assertNever(value: never, message?: string): never {\n throw new Error(message ?? `graphorin: unhandled discriminated-union variant: ${String(value)}`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,YAAY,OAAc,SAAyB;AACjE,OAAM,IAAI,MAAM,WAAW,qDAAqD,OAAO,MAAM,GAAG"}
1
+ {"version":3,"file":"assert-never.js","names":[],"sources":["../../src/utils/assert-never.ts"],"sourcesContent":["/**\n * Exhaustiveness helper. Place at the end of a `switch (...)` over a\n * discriminated union: TypeScript narrows the operand to `never` if\n * every variant is handled. Adding a new variant later turns the call\n * site into a compile error - the regression net for our event unions.\n *\n * @example\n * ```ts\n * function describe(event: AgentEvent): string {\n * switch (event.type) {\n * case 'agent.start': return 'started';\n * case 'agent.end': return 'ended';\n * // ... every other variant ...\n * default:\n * return assertNever(event, 'Unhandled AgentEvent variant');\n * }\n * }\n * ```\n *\n * @stable\n */\nexport function assertNever(value: never, message?: string): never {\n throw new Error(message ?? `graphorin: unhandled discriminated-union variant: ${String(value)}`);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAqBA,SAAgB,YAAY,OAAc,SAAyB;AACjE,OAAM,IAAI,MAAM,WAAW,qDAAqD,OAAO,MAAM,GAAG"}
@@ -3,22 +3,24 @@
3
3
  * MD5 hex digest. Used by the memory layer for content deduplication
4
4
  * (`MD5(content)` is the dedup key for incoming facts / messages).
5
5
  *
6
- * MD5 is **not** a cryptographic primitive in this codebase — it's used
7
- * exclusively for collision-resistant content addressing where
8
- * collision-resistance is the desired property, not pre-image resistance.
9
- * Do not use this helper for password hashing, MAC, or any other
10
- * security-sensitive use case (use `@graphorin/security` for those).
6
+ * MD5 is **not** collision-resistant (practical chosen-prefix
7
+ * collisions exist) and is **not** used as a cryptographic primitive
8
+ * here - it is a fast content-addressing convenience where an
9
+ * adversarial collision merely suppresses a duplicate memory write.
10
+ * Do not use this helper for password hashing, MAC, tamper evidence,
11
+ * or any other security-sensitive use case (use `@graphorin/security`
12
+ * for those; the audit log uses SHA-256).
11
13
  *
12
14
  * @stable
13
15
  */
14
16
  declare function md5(content: string | Uint8Array): string;
15
17
  /**
16
18
  * Pure-JS XXH32 implementation. Used by the memory-modification guard
17
- * fast, non-cryptographic content fingerprinting (`xxhash(content)`
19
+ * - fast, non-cryptographic content fingerprinting (`xxhash(content)`
18
20
  * tracks whether a tool's view of memory has shifted while the LLM was
19
21
  * thinking).
20
22
  *
21
- * Not security-sensitive never use for tampering detection of an
23
+ * Not security-sensitive - never use for tampering detection of an
22
24
  * untrusted attacker; for that the audit log uses SHA-256 (in
23
25
  * `@graphorin/security`).
24
26
  *
@@ -1 +1 @@
1
- {"version":3,"file":"hash.d.ts","names":[],"sources":["../../src/utils/hash.ts"],"sourcesContent":[],"mappings":";;AAcA;AAsBA;;;;;;;;;;iBAtBgB,GAAA,mBAAsB;;;;;;;;;;;;;iBAsBtB,MAAA,iBAAuB"}
1
+ {"version":3,"file":"hash.d.ts","names":[],"sources":["../../src/utils/hash.ts"],"sourcesContent":[],"mappings":";;AAgBA;AAsBA;;;;;;;;;;;;iBAtBgB,GAAA,mBAAsB;;;;;;;;;;;;;iBAsBtB,MAAA,iBAAuB"}
@@ -5,11 +5,13 @@ import { createHash } from "node:crypto";
5
5
  * MD5 hex digest. Used by the memory layer for content deduplication
6
6
  * (`MD5(content)` is the dedup key for incoming facts / messages).
7
7
  *
8
- * MD5 is **not** a cryptographic primitive in this codebase — it's used
9
- * exclusively for collision-resistant content addressing where
10
- * collision-resistance is the desired property, not pre-image resistance.
11
- * Do not use this helper for password hashing, MAC, or any other
12
- * security-sensitive use case (use `@graphorin/security` for those).
8
+ * MD5 is **not** collision-resistant (practical chosen-prefix
9
+ * collisions exist) and is **not** used as a cryptographic primitive
10
+ * here - it is a fast content-addressing convenience where an
11
+ * adversarial collision merely suppresses a duplicate memory write.
12
+ * Do not use this helper for password hashing, MAC, tamper evidence,
13
+ * or any other security-sensitive use case (use `@graphorin/security`
14
+ * for those; the audit log uses SHA-256).
13
15
  *
14
16
  * @stable
15
17
  */
@@ -21,11 +23,11 @@ function md5(content) {
21
23
  }
22
24
  /**
23
25
  * Pure-JS XXH32 implementation. Used by the memory-modification guard
24
- * fast, non-cryptographic content fingerprinting (`xxhash(content)`
26
+ * - fast, non-cryptographic content fingerprinting (`xxhash(content)`
25
27
  * tracks whether a tool's view of memory has shifted while the LLM was
26
28
  * thinking).
27
29
  *
28
- * Not security-sensitive never use for tampering detection of an
30
+ * Not security-sensitive - never use for tampering detection of an
29
31
  * untrusted attacker; for that the audit log uses SHA-256 (in
30
32
  * `@graphorin/security`).
31
33
  *
@@ -1 +1 @@
1
- {"version":3,"file":"hash.js","names":["h32: number"],"sources":["../../src/utils/hash.ts"],"sourcesContent":["import { createHash } from 'node:crypto';\n\n/**\n * MD5 hex digest. Used by the memory layer for content deduplication\n * (`MD5(content)` is the dedup key for incoming facts / messages).\n *\n * MD5 is **not** a cryptographic primitive in this codebase it's used\n * exclusively for collision-resistant content addressing where\n * collision-resistance is the desired property, not pre-image resistance.\n * Do not use this helper for password hashing, MAC, or any other\n * security-sensitive use case (use `@graphorin/security` for those).\n *\n * @stable\n */\nexport function md5(content: string | Uint8Array): string {\n const h = createHash('md5');\n if (typeof content === 'string') {\n h.update(content, 'utf8');\n } else {\n h.update(content);\n }\n return h.digest('hex');\n}\n\n/**\n * Pure-JS XXH32 implementation. Used by the memory-modification guard\n * fast, non-cryptographic content fingerprinting (`xxhash(content)`\n * tracks whether a tool's view of memory has shifted while the LLM was\n * thinking).\n *\n * Not security-sensitive never use for tampering detection of an\n * untrusted attacker; for that the audit log uses SHA-256 (in\n * `@graphorin/security`).\n *\n * @stable\n */\nexport function xxhash(input: string | Uint8Array, seed = 0): string {\n const bytes = typeof input === 'string' ? utf8Encode(input) : input;\n const h = xxh32(bytes, seed >>> 0);\n return h.toString(16).padStart(8, '0');\n}\n\nconst PRIME32_1 = 0x9e3779b1 >>> 0;\nconst PRIME32_2 = 0x85ebca77 >>> 0;\nconst PRIME32_3 = 0xc2b2ae3d >>> 0;\nconst PRIME32_4 = 0x27d4eb2f >>> 0;\nconst PRIME32_5 = 0x165667b1 >>> 0;\n\nconst utf8 = new TextEncoder();\nfunction utf8Encode(s: string): Uint8Array {\n return utf8.encode(s);\n}\n\nfunction rotl32(x: number, r: number): number {\n return ((x << r) | (x >>> (32 - r))) >>> 0;\n}\n\nfunction mul32(a: number, b: number): number {\n // Multiply two 32-bit unsigned ints with overflow truncation.\n const aLo = a & 0xffff;\n const aHi = a >>> 16;\n const bLo = b & 0xffff;\n const bHi = b >>> 16;\n return (aLo * bLo + (((aLo * bHi + aHi * bLo) << 16) >>> 0)) >>> 0;\n}\n\nfunction read32LE(buf: Uint8Array, offset: number): number {\n const b0 = buf[offset] ?? 0;\n const b1 = buf[offset + 1] ?? 0;\n const b2 = buf[offset + 2] ?? 0;\n const b3 = buf[offset + 3] ?? 0;\n return (b0 | (b1 << 8) | (b2 << 16) | (b3 << 24)) >>> 0;\n}\n\nfunction xxh32(input: Uint8Array, seed: number): number {\n const len = input.length;\n let h32: number;\n let i = 0;\n\n if (len >= 16) {\n let v1 = (seed + PRIME32_1 + PRIME32_2) >>> 0;\n let v2 = (seed + PRIME32_2) >>> 0;\n let v3 = seed >>> 0;\n let v4 = (seed - PRIME32_1) >>> 0;\n\n while (i + 16 <= len) {\n v1 = mul32(rotl32((v1 + mul32(read32LE(input, i), PRIME32_2)) >>> 0, 13), PRIME32_1);\n i += 4;\n v2 = mul32(rotl32((v2 + mul32(read32LE(input, i), PRIME32_2)) >>> 0, 13), PRIME32_1);\n i += 4;\n v3 = mul32(rotl32((v3 + mul32(read32LE(input, i), PRIME32_2)) >>> 0, 13), PRIME32_1);\n i += 4;\n v4 = mul32(rotl32((v4 + mul32(read32LE(input, i), PRIME32_2)) >>> 0, 13), PRIME32_1);\n i += 4;\n }\n\n h32 = (rotl32(v1, 1) + rotl32(v2, 7) + rotl32(v3, 12) + rotl32(v4, 18)) >>> 0;\n } else {\n h32 = (seed + PRIME32_5) >>> 0;\n }\n\n h32 = (h32 + len) >>> 0;\n\n while (i + 4 <= len) {\n h32 = mul32(rotl32((h32 + mul32(read32LE(input, i), PRIME32_3)) >>> 0, 17), PRIME32_4);\n i += 4;\n }\n\n while (i < len) {\n const byte = input[i] ?? 0;\n h32 = mul32(rotl32((h32 + mul32(byte >>> 0, PRIME32_5)) >>> 0, 11), PRIME32_1);\n i++;\n }\n\n h32 = mul32(h32 ^ (h32 >>> 15), PRIME32_2);\n h32 = mul32(h32 ^ (h32 >>> 13), PRIME32_3);\n h32 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\n\n/**\n * MD5 hex digest. Used by the memory layer for content deduplication\n * (`MD5(content)` is the dedup key for incoming facts / messages).\n *\n * MD5 is **not** collision-resistant (practical chosen-prefix\n * collisions exist) and is **not** used as a cryptographic primitive\n * here - it is a fast content-addressing convenience where an\n * adversarial collision merely suppresses a duplicate memory write.\n * Do not use this helper for password hashing, MAC, tamper evidence,\n * or any other security-sensitive use case (use `@graphorin/security`\n * for those; the audit log uses SHA-256).\n *\n * @stable\n */\nexport function md5(content: string | Uint8Array): string {\n const h = createHash('md5');\n if (typeof content === 'string') {\n h.update(content, 'utf8');\n } else {\n h.update(content);\n }\n return h.digest('hex');\n}\n\n/**\n * Pure-JS XXH32 implementation. Used by the memory-modification guard\n * - fast, non-cryptographic content fingerprinting (`xxhash(content)`\n * tracks whether a tool's view of memory has shifted while the LLM was\n * thinking).\n *\n * Not security-sensitive - never use for tampering detection of an\n * untrusted attacker; for that the audit log uses SHA-256 (in\n * `@graphorin/security`).\n *\n * @stable\n */\nexport function xxhash(input: string | Uint8Array, seed = 0): string {\n const bytes = typeof input === 'string' ? utf8Encode(input) : input;\n const h = xxh32(bytes, seed >>> 0);\n return h.toString(16).padStart(8, '0');\n}\n\nconst PRIME32_1 = 0x9e3779b1 >>> 0;\nconst PRIME32_2 = 0x85ebca77 >>> 0;\nconst PRIME32_3 = 0xc2b2ae3d >>> 0;\nconst PRIME32_4 = 0x27d4eb2f >>> 0;\nconst PRIME32_5 = 0x165667b1 >>> 0;\n\nconst utf8 = new TextEncoder();\nfunction utf8Encode(s: string): Uint8Array {\n return utf8.encode(s);\n}\n\nfunction rotl32(x: number, r: number): number {\n return ((x << r) | (x >>> (32 - r))) >>> 0;\n}\n\nfunction mul32(a: number, b: number): number {\n // Multiply two 32-bit unsigned ints with overflow truncation.\n const aLo = a & 0xffff;\n const aHi = a >>> 16;\n const bLo = b & 0xffff;\n const bHi = b >>> 16;\n return (aLo * bLo + (((aLo * bHi + aHi * bLo) << 16) >>> 0)) >>> 0;\n}\n\nfunction read32LE(buf: Uint8Array, offset: number): number {\n const b0 = buf[offset] ?? 0;\n const b1 = buf[offset + 1] ?? 0;\n const b2 = buf[offset + 2] ?? 0;\n const b3 = buf[offset + 3] ?? 0;\n return (b0 | (b1 << 8) | (b2 << 16) | (b3 << 24)) >>> 0;\n}\n\nfunction xxh32(input: Uint8Array, seed: number): number {\n const len = input.length;\n let h32: number;\n let i = 0;\n\n if (len >= 16) {\n let v1 = (seed + PRIME32_1 + PRIME32_2) >>> 0;\n let v2 = (seed + PRIME32_2) >>> 0;\n let v3 = seed >>> 0;\n let v4 = (seed - PRIME32_1) >>> 0;\n\n while (i + 16 <= len) {\n v1 = mul32(rotl32((v1 + mul32(read32LE(input, i), PRIME32_2)) >>> 0, 13), PRIME32_1);\n i += 4;\n v2 = mul32(rotl32((v2 + mul32(read32LE(input, i), PRIME32_2)) >>> 0, 13), PRIME32_1);\n i += 4;\n v3 = mul32(rotl32((v3 + mul32(read32LE(input, i), PRIME32_2)) >>> 0, 13), PRIME32_1);\n i += 4;\n v4 = mul32(rotl32((v4 + mul32(read32LE(input, i), PRIME32_2)) >>> 0, 13), PRIME32_1);\n i += 4;\n }\n\n h32 = (rotl32(v1, 1) + rotl32(v2, 7) + rotl32(v3, 12) + rotl32(v4, 18)) >>> 0;\n } else {\n h32 = (seed + PRIME32_5) >>> 0;\n }\n\n h32 = (h32 + len) >>> 0;\n\n while (i + 4 <= len) {\n h32 = mul32(rotl32((h32 + mul32(read32LE(input, i), PRIME32_3)) >>> 0, 17), PRIME32_4);\n i += 4;\n }\n\n while (i < len) {\n const byte = input[i] ?? 0;\n h32 = mul32(rotl32((h32 + mul32(byte >>> 0, PRIME32_5)) >>> 0, 11), PRIME32_1);\n i++;\n }\n\n h32 = mul32(h32 ^ (h32 >>> 15), PRIME32_2);\n h32 = mul32(h32 ^ (h32 >>> 13), PRIME32_3);\n h32 = (h32 ^ (h32 >>> 16)) >>> 0;\n\n return h32;\n}\n"],"mappings":";;;;;;;;;;;;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;EAClB,IAAI,KAAM,OAAO,cAAe;AAEhC,SAAO,IAAI,MAAM,KAAK;AACpB,QAAK,MAAM,OAAQ,KAAK,MAAM,SAAS,OAAO,EAAE,EAAE,UAAU,KAAM,GAAG,GAAG,EAAE,UAAU;AACpF,QAAK;AACL,QAAK,MAAM,OAAQ,KAAK,MAAM,SAAS,OAAO,EAAE,EAAE,UAAU,KAAM,GAAG,GAAG,EAAE,UAAU;AACpF,QAAK;AACL,QAAK,MAAM,OAAQ,KAAK,MAAM,SAAS,OAAO,EAAE,EAAE,UAAU,KAAM,GAAG,GAAG,EAAE,UAAU;AACpF,QAAK;AACL,QAAK,MAAM,OAAQ,KAAK,MAAM,SAAS,OAAO,EAAE,EAAE,UAAU,KAAM,GAAG,GAAG,EAAE,UAAU;AACpF,QAAK;;AAGP,QAAO,OAAO,IAAI,EAAE,GAAG,OAAO,IAAI,EAAE,GAAG,OAAO,IAAI,GAAG,GAAG,OAAO,IAAI,GAAG,KAAM;OAE5E,OAAO,OAAO,cAAe;AAG/B,OAAO,MAAM,QAAS;AAEtB,QAAO,IAAI,KAAK,KAAK;AACnB,QAAM,MAAM,OAAQ,MAAM,MAAM,SAAS,OAAO,EAAE,EAAE,UAAU,KAAM,GAAG,GAAG,EAAE,UAAU;AACtF,OAAK;;AAGP,QAAO,IAAI,KAAK;EACd,MAAM,OAAO,MAAM,MAAM;AACzB,QAAM,MAAM,OAAQ,MAAM,MAAM,SAAS,GAAG,UAAU,KAAM,GAAG,GAAG,EAAE,UAAU;AAC9E;;AAGF,OAAM,MAAM,MAAO,QAAQ,IAAK,UAAU;AAC1C,OAAM,MAAM,MAAO,QAAQ,IAAK,UAAU;AAC1C,QAAO,MAAO,QAAQ,QAAS;AAE/B,QAAO"}
@@ -48,7 +48,7 @@ type ValidationResult<T> = {
48
48
  };
49
49
  /**
50
50
  * Synchronous validation wrapper. Does **not** swallow errors thrown by
51
- * the schema's transformations only normalizes the success / failure
51
+ * the schema's transformations - only normalizes the success / failure
52
52
  * signal.
53
53
  *
54
54
  * @stable
@@ -1,7 +1,7 @@
1
1
  //#region src/utils/validation.ts
2
2
  /**
3
3
  * Synchronous validation wrapper. Does **not** swallow errors thrown by
4
- * the schema's transformations only normalizes the success / failure
4
+ * the schema's transformations - only normalizes the success / failure
5
5
  * signal.
6
6
  *
7
7
  * @stable
@@ -1 +1 @@
1
- {"version":3,"file":"validation.js","names":[],"sources":["../../src/utils/validation.ts"],"sourcesContent":["/**\n * Type-only Zod compatibility shim. We declare a structural type for the\n * subset of `zod` we depend on so that `@graphorin/core` can be type-\n * checked without importing zod directly. Consumers that do `import {\n * z } from 'zod'` get the real types via the user's `zod` install (the\n * peer dependency).\n *\n * @stable\n */\nexport interface ZodLikeSchema<TOutput = unknown, TInput = unknown> {\n parse(data: unknown): TOutput;\n safeParse(data: unknown): ZodLikeSafeParseResult<TOutput, TInput>;\n /** Internal phantom used by Zod for inference. We don't dereference it. */\n readonly _output?: TOutput;\n readonly _input?: TInput;\n}\n\n/** @stable */\nexport type ZodLikeSafeParseResult<TOutput, TInput> =\n | { readonly success: true; readonly data: TOutput }\n | { readonly success: false; readonly error: ZodLikeError<TInput> };\n\n/** @stable */\nexport interface ZodLikeError<_TInput = unknown> {\n readonly name: string;\n readonly message: string;\n readonly issues: ReadonlyArray<{\n readonly path: ReadonlyArray<string | number>;\n readonly message: string;\n }>;\n}\n\n/**\n * Validate `data` against `schema` and return a `Result` instead of\n * throwing. Use this in code paths where you want explicit\n * pattern-matching over success / failure.\n *\n * @stable\n */\nexport type ValidationResult<T> =\n | { readonly ok: true; readonly value: T }\n | { readonly ok: false; readonly error: ZodLikeError };\n\n/**\n * Synchronous validation wrapper. Does **not** swallow errors thrown by\n * the schema's transformations only normalizes the success / failure\n * signal.\n *\n * @stable\n */\nexport function validate<T>(schema: ZodLikeSchema<T>, data: unknown): ValidationResult<T> {\n const result = schema.safeParse(data);\n if (result.success) return { ok: true, value: result.data };\n return { ok: false, error: result.error };\n}\n\n/**\n * Throwing variant of `validate(...)` that surfaces a `TypeError` carrying\n * a stable, parser-style message. Useful at module-boundary entry points\n * where a thrown error is the natural failure mode.\n *\n * @stable\n */\nexport function validateOrThrow<T>(schema: ZodLikeSchema<T>, data: unknown, what?: string): T {\n const r = validate(schema, data);\n if (r.ok) return r.value;\n const summary = r.error.issues.map((i) => `${i.path.join('.') || '.'}: ${i.message}`).join('; ');\n throw new TypeError(`graphorin: validation failed${what ? ` for ${what}` : ''}: ${summary}`);\n}\n"],"mappings":";;;;;;;;AAkDA,SAAgB,SAAY,QAA0B,MAAoC;CACxF,MAAM,SAAS,OAAO,UAAU,KAAK;AACrC,KAAI,OAAO,QAAS,QAAO;EAAE,IAAI;EAAM,OAAO,OAAO;EAAM;AAC3D,QAAO;EAAE,IAAI;EAAO,OAAO,OAAO;EAAO;;;;;;;;;AAU3C,SAAgB,gBAAmB,QAA0B,MAAe,MAAkB;CAC5F,MAAM,IAAI,SAAS,QAAQ,KAAK;AAChC,KAAI,EAAE,GAAI,QAAO,EAAE;CACnB,MAAM,UAAU,EAAE,MAAM,OAAO,KAAK,MAAM,GAAG,EAAE,KAAK,KAAK,IAAI,IAAI,IAAI,IAAI,EAAE,UAAU,CAAC,KAAK,KAAK;AAChG,OAAM,IAAI,UAAU,+BAA+B,OAAO,QAAQ,SAAS,GAAG,IAAI,UAAU"}
1
+ {"version":3,"file":"validation.js","names":[],"sources":["../../src/utils/validation.ts"],"sourcesContent":["/**\n * Type-only Zod compatibility shim. We declare a structural type for the\n * subset of `zod` we depend on so that `@graphorin/core` can be type-\n * checked without importing zod directly. Consumers that do `import {\n * z } from 'zod'` get the real types via the user's `zod` install (the\n * peer dependency).\n *\n * @stable\n */\nexport interface ZodLikeSchema<TOutput = unknown, TInput = unknown> {\n parse(data: unknown): TOutput;\n safeParse(data: unknown): ZodLikeSafeParseResult<TOutput, TInput>;\n /** Internal phantom used by Zod for inference. We don't dereference it. */\n readonly _output?: TOutput;\n readonly _input?: TInput;\n}\n\n/** @stable */\nexport type ZodLikeSafeParseResult<TOutput, TInput> =\n | { readonly success: true; readonly data: TOutput }\n | { readonly success: false; readonly error: ZodLikeError<TInput> };\n\n/** @stable */\nexport interface ZodLikeError<_TInput = unknown> {\n readonly name: string;\n readonly message: string;\n readonly issues: ReadonlyArray<{\n readonly path: ReadonlyArray<string | number>;\n readonly message: string;\n }>;\n}\n\n/**\n * Validate `data` against `schema` and return a `Result` instead of\n * throwing. Use this in code paths where you want explicit\n * pattern-matching over success / failure.\n *\n * @stable\n */\nexport type ValidationResult<T> =\n | { readonly ok: true; readonly value: T }\n | { readonly ok: false; readonly error: ZodLikeError };\n\n/**\n * Synchronous validation wrapper. Does **not** swallow errors thrown by\n * the schema's transformations - only normalizes the success / failure\n * signal.\n *\n * @stable\n */\nexport function validate<T>(schema: ZodLikeSchema<T>, data: unknown): ValidationResult<T> {\n const result = schema.safeParse(data);\n if (result.success) return { ok: true, value: result.data };\n return { ok: false, error: result.error };\n}\n\n/**\n * Throwing variant of `validate(...)` that surfaces a `TypeError` carrying\n * a stable, parser-style message. Useful at module-boundary entry points\n * where a thrown error is the natural failure mode.\n *\n * @stable\n */\nexport function validateOrThrow<T>(schema: ZodLikeSchema<T>, data: unknown, what?: string): T {\n const r = validate(schema, data);\n if (r.ok) return r.value;\n const summary = r.error.issues.map((i) => `${i.path.join('.') || '.'}: ${i.message}`).join('; ');\n throw new TypeError(`graphorin: validation failed${what ? ` for ${what}` : ''}: ${summary}`);\n}\n"],"mappings":";;;;;;;;AAkDA,SAAgB,SAAY,QAA0B,MAAoC;CACxF,MAAM,SAAS,OAAO,UAAU,KAAK;AACrC,KAAI,OAAO,QAAS,QAAO;EAAE,IAAI;EAAM,OAAO,OAAO;EAAM;AAC3D,QAAO;EAAE,IAAI;EAAO,OAAO,OAAO;EAAO;;;;;;;;;AAU3C,SAAgB,gBAAmB,QAA0B,MAAe,MAAkB;CAC5F,MAAM,IAAI,SAAS,QAAQ,KAAK;AAChC,KAAI,EAAE,GAAI,QAAO,EAAE;CACnB,MAAM,UAAU,EAAE,MAAM,OAAO,KAAK,MAAM,GAAG,EAAE,KAAK,KAAK,IAAI,IAAI,IAAI,IAAI,EAAE,UAAU,CAAC,KAAK,KAAK;AAChG,OAAM,IAAI,UAAU,+BAA+B,OAAO,QAAQ,SAAS,GAAG,IAAI,UAAU"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@graphorin/core",
3
- "version": "0.5.0",
3
+ "version": "0.6.0",
4
4
  "description": "Core types, contracts, and utilities for the Graphorin framework. Dependency-free root package every other @graphorin/* package depends on.",
5
5
  "license": "MIT",
6
6
  "author": "Oleksiy Stepurenko",