@hanfani/core 0.1.1 → 0.1.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 (2) hide show
  1. package/README.md +66 -16
  2. package/package.json +13 -3
package/README.md CHANGED
@@ -13,22 +13,72 @@ proves any provider honours that at runtime.
13
13
 
14
14
  ## Exports
15
15
 
16
- - **Definitions:** `defineAgent`, `defineWorkflow`, `definePrompt`,
17
- `defineProviders`, `AgentDefinitionSchema`.
18
- - **Messages:** `isAssistant`, `isToolMessage`, `toolCallsOf`,
19
- `hasPendingApproval`, `pairToolResults`, `lastApprovalArgs`,
20
- `resolvedApprovalCount`, `approvalResolved`.
21
- - **Handoffs:** `encodeHandoff`, `decodeHandoff`, `handoffNote`,
22
- `HandoffPayloadSchema`, `TicketHandoffPayloadSchema`.
23
- - **Gates & events:** `gateOpened`, `readGateOpened`, `GATE_OPENED`,
24
- `GateOpenedValueSchema`, `lifecycleNote`, `LIFECYCLE_NOTE_TEXT`,
25
- `foldEventsToMessages`.
26
- - **Lifecycle & delivery:** `lifecycle`, `hasLiveDescendant`, `resolveDelivery`,
27
- `instanceId`, `composeInstructions`.
28
- - **Providers & integration:** `providerConformanceChecks`, `aggregateHealth`,
29
- `isOk`, `isOAuth2`.
30
- - Plus the full type surface (`WorkflowDescriptor`, `Outcome`, `Phase`,
31
- `Provider`, `EffectFn`, `AuthSpec`, `ResolvedCredential`, …).
16
+ ### Definitions
17
+
18
+ | Export | Description |
19
+ | --- | --- |
20
+ | `defineAgent` | Validate and construct an agent definition; enforces that every `effect` is a gated `approval`. |
21
+ | `defineWorkflow` | Validate a workflow descriptor (unique agent ids, role:input entry agent, in-workflow handoffs, unique inputs) and return it. |
22
+ | `definePrompt` | Build a prompt strategy from `onStart` / `onInput` / `onResume` handlers. |
23
+ | `defineProviders` | Build a provider registry that resolves provider factories by name. |
24
+ | `AgentDefinitionSchema` | The Zod schema backing `defineAgent`. |
25
+
26
+ ### Messages
27
+
28
+ | Export | Description |
29
+ | --- | --- |
30
+ | `isAssistant` | Type guard for assistant messages. |
31
+ | `isToolMessage` | Type guard for tool-result messages. |
32
+ | `toolCallsOf` | Extract the tool calls from a message. |
33
+ | `hasPendingApproval` | True when an approval tool was called but has no tool result yet. |
34
+ | `pairToolResults` | Map each tool result to the `toolCallId` it answers. |
35
+ | `lastApprovalArgs` | Parsed arguments of the most recent approval tool call, or `null`. |
36
+ | `resolvedApprovalCount` | How many approval calls have a matching tool result. |
37
+ | `approvalResolved` | True when at least one approval call has resolved. |
38
+
39
+ ### Handoffs
40
+
41
+ | Export | Description |
42
+ | --- | --- |
43
+ | `encodeHandoff` | Encode a payload as a user message downstream agents can decode. |
44
+ | `decodeHandoff` | Decode and validate the latest handoff payload from run input. |
45
+ | `handoffNote` | Emit a handoff note event. |
46
+ | `HandoffPayloadSchema` | Zod schema for a generic thread/email handoff payload. |
47
+ | `TicketHandoffPayloadSchema` | Zod schema for a ticket/issue handoff payload. |
48
+
49
+ ### Gates & events
50
+
51
+ | Export | Description |
52
+ | --- | --- |
53
+ | `gateOpened` | Emit the custom event that opens a human-approval gate. |
54
+ | `readGateOpened` | Read a `GATE_OPENED` value off an event, or `null`. |
55
+ | `GATE_OPENED` | The gate-opened custom event name constant. |
56
+ | `GateOpenedValueSchema` | Zod schema for a gate-opened value. |
57
+ | `lifecycleNote` | Emit a lifecycle note event. |
58
+ | `LIFECYCLE_NOTE_TEXT` | Human-readable label for each terminal outcome. |
59
+ | `foldEventsToMessages` | Fold an ag-ui event stream into a flat list of messages. |
60
+
61
+ ### Lifecycle & delivery
62
+
63
+ | Export | Description |
64
+ | --- | --- |
65
+ | `lifecycle` | Derive display lifecycle (`isLive` / `isVisible` / `covers`) from phase + outcome. |
66
+ | `hasLiveDescendant` | Set of ids that have a live descendant in a parent/child tree. |
67
+ | `resolveDelivery` | Resolve where a payload should be delivered (agent or contract). |
68
+ | `instanceId` | Stable `workflow__agent` instance id. |
69
+ | `composeInstructions` | Prepend the workflow prompt to an agent's instructions. |
70
+
71
+ ### Providers & integration
72
+
73
+ | Export | Description |
74
+ | --- | --- |
75
+ | `providerConformanceChecks` | Provider-agnostic suite proving a provider honours the gate/effect contract. |
76
+ | `aggregateHealth` | Return the first failing health check, or an ok result. |
77
+ | `isOk` | Narrow a `HealthCheck` to its ok variant. |
78
+ | `isOAuth2` | Narrow an `AuthSpec` to its oauth2 variant. |
79
+
80
+ Plus the full type surface: `WorkflowDescriptor`, `Outcome`, `Phase`, `Provider`,
81
+ `EffectFn`, `AuthSpec`, `ResolvedCredential`, and more.
32
82
 
33
83
  ## Build & test
34
84
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hanfani/core",
3
- "version": "0.1.1",
3
+ "version": "0.1.2",
4
4
  "description": "Headless engine and types for the Hanfani agent framework.",
5
5
  "license": "MIT",
6
6
  "author": "Aziz Mashkour",
@@ -19,10 +19,13 @@
19
19
  "publishConfig": {
20
20
  "access": "public"
21
21
  },
22
+ "homepage": "https://github.com/fruitizz/hanfani-core#readme",
22
23
  "repository": {
23
24
  "type": "git",
24
- "url": "git+https://github.com/azizmashkour/hanfani-packages.git",
25
- "directory": "packages/core"
25
+ "url": "git+https://github.com/fruitizz/hanfani-core.git"
26
+ },
27
+ "bugs": {
28
+ "url": "https://github.com/fruitizz/hanfani-core/issues"
26
29
  },
27
30
  "keywords": [
28
31
  "hanfani",
@@ -35,6 +38,13 @@
35
38
  "@ag-ui/client": "^0.0.55",
36
39
  "zod": "^3.25.76"
37
40
  },
41
+ "engines": {
42
+ "node": ">=20.19"
43
+ },
44
+ "devDependencies": {
45
+ "typescript": "^7.0.2",
46
+ "vitest": "^2.1.0"
47
+ },
38
48
  "scripts": {
39
49
  "build": "tsc -p tsconfig.build.json",
40
50
  "typecheck": "tsc -p tsconfig.json --noEmit",