@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.
- package/LICENSE +1 -1
- package/README.md +26 -82
- package/package.json +2 -2
package/LICENSE
CHANGED
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
|
|
6
|
-
|
|
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
|
-
>
|
|
8
|
+
> **The agent proposes, a human approves, the server acts.**
|
|
9
9
|
|
|
10
|
-
`defineAgent` refuses any
|
|
11
|
-
|
|
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
|
-
##
|
|
13
|
+
## Install
|
|
15
14
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
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
|
-
|
|
81
|
-
|
|
21
|
+
```ts
|
|
22
|
+
import { defineAgent } from '@hanfani/core'
|
|
82
23
|
|
|
83
|
-
|
|
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
|
-
|
|
86
|
-
compiler-API tooling, so nothing here breaks on the TS 7 upgrade.
|
|
35
|
+
## Docs
|
|
87
36
|
|
|
88
|
-
|
|
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
|
-
##
|
|
39
|
+
## License
|
|
95
40
|
|
|
96
|
-
|
|
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.
|
|
3
|
+
"version": "0.1.3",
|
|
4
4
|
"description": "Headless engine and types for the Hanfani agent framework.",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"author": "
|
|
6
|
+
"author": "Fruitizz",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"sideEffects": false,
|
|
9
9
|
"files": [
|