@hanfani/core 0.1.2 → 0.1.3

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 (3) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +26 -82
  3. package/package.json +2 -2
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  MIT License
2
2
 
3
- Copyright (c) 2026 Aziz Mashkour
3
+ Copyright (c) 2026 Fruitizz
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -2,96 +2,40 @@
2
2
 
3
3
  Headless engine and types for the Hanfani agent framework.
4
4
 
5
- Pure logic — no I/O, no server, no React. This is the layer that defines what a
6
- workflow and an agent *are* and enforces the framework's one safety invariant:
5
+ Pure logic — no I/O, no server, no UI. It defines what a workflow and an agent
6
+ *are* and enforces one rule:
7
7
 
8
- > An agent proposes, a human approves, the server acts.
8
+ > **The agent proposes, a human approves, the server acts.**
9
9
 
10
- `defineAgent` refuses any `effect` that isn't also an `approval`, so a side
11
- effect can never be wired to fire without a human gate. `providerConformanceChecks`
12
- proves any provider honours that at runtime.
10
+ `defineAgent` refuses any side effect that isn't behind a human-approval gate,
11
+ and `providerConformanceChecks` proves any model provider honors that at runtime.
13
12
 
14
- ## Exports
13
+ ## Install
15
14
 
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
15
+ ```bash
16
+ pnpm add @hanfani/core
17
+ ```
72
18
 
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. |
19
+ ## Quick look
79
20
 
80
- Plus the full type surface: `WorkflowDescriptor`, `Outcome`, `Phase`, `Provider`,
81
- `EffectFn`, `AuthSpec`, `ResolvedCredential`, and more.
21
+ ```ts
22
+ import { defineAgent } from '@hanfani/core'
82
23
 
83
- ## Build & test
24
+ const reply = defineAgent({
25
+ id: 'reply',
26
+ name: 'Reply',
27
+ provider: 'claude',
28
+ instructions: 'Draft a reply for the human to approve.',
29
+ tools: ['saveDraft'],
30
+ approvals: ['saveDraft'], // saveDraft only fires after a human approves
31
+ renders: { saveDraft: 'DraftCard' },
32
+ })
33
+ ```
84
34
 
85
- Built with the native TypeScript 7 compiler (`tsc` / tsgo) — no bundler, no
86
- compiler-API tooling, so nothing here breaks on the TS 7 upgrade.
35
+ ## Docs
87
36
 
88
- ```bash
89
- pnpm build # tsc -p tsconfig.build.json → dist/*.js + dist/*.d.ts
90
- pnpm typecheck # tsc -p tsconfig.json --noEmit
91
- pnpm test # vitest smoke suite
92
- ```
37
+ Full API reference and guides are coming soon in the Hanfani framework docs.
93
38
 
94
- ## Peer runtime
39
+ ## License
95
40
 
96
- Depends on `@ag-ui/client` (event/message types) and `zod` (schemas). Both are
97
- declared as regular dependencies.
41
+ [MIT](./LICENSE) License © [Fruitizz](https://github.com/fruitizz)
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@hanfani/core",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "Headless engine and types for the Hanfani agent framework.",
5
5
  "license": "MIT",
6
- "author": "Aziz Mashkour",
6
+ "author": "Fruitizz",
7
7
  "type": "module",
8
8
  "sideEffects": false,
9
9
  "files": [