@felspar/sdk 0.2.0 → 0.3.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.
package/README.md CHANGED
@@ -1,20 +1,10 @@
1
1
  # @felspar/sdk
2
2
 
3
- Felspar is a shared, versioned decision system for enterprise agents. A
4
- company's approved meaning, the evidence a decision needs and the decision
5
- itself travel together in a released Decision Pack. Agents ask Felspar for a
6
- decision, get a receipt they can verify, and act only on what Felspar decided.
7
-
8
- This package connects an agent to Felspar: an [Eve](https://github.com/vercel/eve)
9
- connection in two lines, a TypeScript client for the hosted Felspar API, an
10
- action gate that keeps an agent's tools from acting without a verified Felspar
11
- decision, and the agent skill for running any Felspar job. It runs on Node.js
12
- 24 or later, and its only dependency is `zod`. The SDK is a transport client:
13
- decisions and policy stay with the Felspar service and the released pack, and
14
- the SDK does not reimplement them.
15
-
16
- The modules under `draft/` may change between minor versions while the API
17
- settles, before 1.0.
3
+ Felspar is a shared, versioned decision system for enterprise agents. A company's approved meaning, the evidence a decision needs and the decision itself travel together in a released Decision Pack. Agents ask Felspar for a decision, get a receipt they can verify, and act only on what Felspar decided.
4
+
5
+ This package connects an agent to Felspar: an [Eve](https://github.com/vercel/eve) connection in two lines, a TypeScript client for the hosted Felspar API, an action gate that keeps an agent's tools from acting without a verified Felspar decision, and the agent skill for running any Felspar job. It runs on Node.js 24 or later, and its only dependency is `zod`. The SDK is a transport client: decisions and policy stay with the Felspar service and the released pack, and the SDK does not reimplement them.
6
+
7
+ The modules under `draft/` may change between minor versions while the API settles, before 1.0.
18
8
 
19
9
  ## Install
20
10
 
@@ -32,12 +22,9 @@ import { felsparConnection } from "@felspar/sdk/eve";
32
22
  export default defineMcpClientConnection(felsparConnection());
33
23
  ```
34
24
 
35
- The agent gets Felspar's `get_job_requirements`, `get_job_decision` and
36
- `check_output` tools and nothing else. The key is the agent's own, created on
37
- the Felspar web page (Workspace → Agents) and read from `FELSPAR_AGENT_KEY`
38
- when Eve connects; the endpoint is `FELSPAR_MCP_URL`, or production. Pass
39
- `{ url, agentKey, description }` to override them. Add the skill (below) so the
40
- agent knows the method.
25
+ The agent gets Felspar's `list_jobs`, `get_job_requirements`, `get_job_decision` and `check_output` tools and nothing else. The key is the agent's own, created on the Felspar web page (Workspace → Agents) and read from `FELSPAR_AGENT_KEY` when Eve connects; the endpoint is `FELSPAR_MCP_URL`, or production. Pass `{ url, agentKey, description }` to override them. Add the skill (below) so the agent knows the method.
26
+
27
+ Over MCP, `get_job_requirements` and `get_job_decision` answer compactly by default. The brief's `input` lists the arguments and a short `facts` example from the job's own questions. The decision keeps what the agent acts on, plus `executionObjectId`, the full `receipt`, the `context` capsule and `explanation.evidenceFreshUntil`, which is what the action gate records and verifies. `detail: "full"` returns the REST brief or result unchanged. The agent sends no execution ID: calling `get_job_decision` again with the same arguments within the same hour returns the decision already made, and `blocked` means that first call is still running. See [MCP tools](https://docs.felspar.ai/reference/mcp-tools).
41
28
 
42
29
  ## Hosted client
43
30
 
@@ -68,18 +55,18 @@ const response = await felspar.resolveFacts(releaseId, {
68
55
  if (response.status === "ready") {
69
56
  console.log(response.result?.outcome, response.result?.receipt);
70
57
  }
58
+
59
+ // The jobs this agent key may run, by ID.
60
+ const { jobs } = await felspar.listJobs();
71
61
  ```
72
62
 
73
- A refused request throws `FelsparRequestError` with the HTTP `status` and the
74
- service's `refusal` (its `error` code and, where there is one, a `fix`).
63
+ How a case is identified comes from the job's description (`identity`): send `entityId` for the record's own ID (`provided`), `identity` field values (`fields`), or nothing (`content`, and the first decision of an `issued` job). The result's `case` gives the case's `id` and `mode`; send `case.id` as `entityId` for every later decision on the same case. Results are typed (`FelsparJobResult`): `case`, `subject` with its `related` records, `escalation` (`id`, `trigger`, `why`) and `missing` for a gap.
64
+
65
+ A refused request throws `FelsparRequestError` with the HTTP `status` and the service's `refusal` (its `error` code, where there is one a `fix`, and any `escalation` it names, such as for `attempt_limit_reached`).
75
66
 
76
67
  ## Action gate
77
68
 
78
- The gate sits in front of a tool that acts, such as writing an email draft or
79
- replying to a ticket. It allows a call only when the call's fields are allowed,
80
- the call is about a case Felspar decided on in this session, Felspar
81
- re-verifies that decision's receipt, and the decided outcome permits the tool.
82
- Any error, and anything unknown or ambiguous, denies.
69
+ The gate sits in front of a tool that acts, such as writing an email draft or replying to a ticket. It allows a call only when the call's fields are allowed, the call is about a case Felspar decided on in this session, Felspar re-verifies that decision's receipt, and the decided outcome permits the tool. Any error, and anything unknown or ambiguous, denies.
83
70
 
84
71
  ```ts
85
72
  import {
@@ -110,31 +97,16 @@ const gate = createActionGate({
110
97
 
111
98
  What a tool may do comes from the released pack, not from the gate's config:
112
99
 
113
- - `writes` names the output the tool writes, by its id in the pack. The call is
114
- allowed only when the released job description lists that output under the
115
- outcome Felspar's replay reports. (A rule may give `outcomes`, a list of
116
- outcome ids, instead; exactly one of the two.)
117
- - `entity` says which case a call is about. By default, every recipient's
118
- email domain must belong to the one company Felspar decided on. With
119
- `{ field }`, that input field must hold the decision's `entity_id` (such as a
120
- ticket ID), trimmed and otherwise exact, case included, as Felspar keys
121
- cases (`HC-1201` and `hc-1201` are two cases). Only email domains match
122
- without case.
123
- Recipients are then not tied to the case, so a tool that can address anyone
124
- should also limit them (`testRecipients`, or the tool's own settings).
125
- - `outputCheck` requires that Felspar passed exactly the text the call sends
126
- for that decision (`check_output`); with `writes`, for that output.
127
-
128
- A denial is `{ allow: false, reason, escalate? }`. `escalate` is the company's
129
- next step, quoted from the released description: the outcome's next step when
130
- the outcome doesn't permit the tool, or what to do when nothing is decided. For
131
- a missing or failed output check it is the fixed instruction to fix what
132
- `check_output` flagged and check again. It is absent when the description
133
- doesn't say. Every adapter below shows it to the
134
- model with the reason.
135
-
136
- Then connect the gate to your agent framework. Tool names must match exactly
137
- as the runtime reports them.
100
+ - `writes` names the output the tool writes, by its id in the pack. The call is allowed only when the released job description lists that output under the outcome Felspar's replay reports. (A rule may give `outcomes`, a list of outcome ids, instead; exactly one of the two.)
101
+ - Which case a call is about comes from the released job's subject and identity. A decision is recorded by the `case.id` Felspar's result names (so an agent that sends no `entity_id`, for an issued, fields or content job, still gets one), and Felspar's replay must name the same case ID and mode. By default:
102
+ - for a job whose subject is a provided, case-insensitive ID such as a web domain (or a release with no subject), every recipient's email domain must belong to the one company Felspar decided on; a decided ID that isn't a company domain allows no recipient, so give such a rule an entity field;
103
+ - for any other job, the call is about the one case decided in the session for this job; with several, the call is denied until the rule names a field.
104
+ - `entity: { field }` overrides that: the input field must hold the case's ID, the record's own ID (such as a ticket ID) or the `case.id` Felspar issued or derived, trimmed and matched by the subject's match rule (exact unless the subject is case-insensitive; with no subject, `HC-1201` and `hc-1201` are two cases). Recipients are then not tied to the case, so a tool that can address anyone should also limit them (`testRecipients`, or the tool's own settings).
105
+ - `outputCheck` requires that Felspar passed exactly the text the call sends for that decision (`check_output`); with `writes`, for that output.
106
+
107
+ A denial is `{ allow: false, reason, escalate?, escalation? }`. `escalate` is the company's next step, quoted from the released description: the outcome's next step when the outcome doesn't permit the tool, or what to do when nothing is decided. For a missing or failed output check it is the fixed instruction to fix what `check_output` flagged and check again. `escalation` is the hand-off the policy names: `{ id, trigger, why }`, with the id from Felspar's replay of the outcome (or the job's unresolved path) and `why` quoted from the release. Both are absent when the release doesn't say. Every adapter below shows them to the model with the reason.
108
+
109
+ Then connect the gate to your agent framework. Tool names must match exactly as the runtime reports them.
138
110
 
139
111
  ### Eve
140
112
 
@@ -174,28 +146,20 @@ toolInputGuardrails: [felsparToolInputGuardrail(gate, { sessionOf })],
174
146
  toolOutputGuardrails: [felsparDecisionOutputGuardrail(gate, { sessionOf })],
175
147
  ```
176
148
 
177
- Outside an agent framework,
178
- `checkAction({ rules, toolName, input, decisions, verify, describe })` returns
179
- the same verdict.
149
+ Outside an agent framework, `checkAction({ rules, toolName, input, decisions, verify, describe })` returns the same verdict.
180
150
 
181
- A Felspar receipt records what Felspar decided from the evidence it was given.
182
- It is not a factual, legal or security certification, and a passed output
183
- check means the text follows the released rules, not that it is true or
184
- approved to send.
151
+ A Felspar receipt records what Felspar decided from the evidence it was given. It is not a factual, legal or security certification, and a passed output check means the text follows the released rules, not that it is true or approved to send.
185
152
 
186
153
  ## Agent skill
187
154
 
188
- The package ships the skill that teaches an agent the method for any Felspar
189
- job: get the requirements, gather exact evidence, get the decision, write and
190
- check what the decision asks for, and escalate with the company's next step.
155
+ The package ships the skill (its version matches the package's) that teaches an agent the method for any Felspar job: get the requirements, gather exact evidence, get the decision, write and check what the decision asks for, and escalate with the company's next step.
191
156
 
192
157
  ```bash
193
158
  npx @felspar/sdk skill # writes agent/skills/felspar/SKILL.md
194
159
  npx @felspar/sdk skill .claude --force
195
160
  ```
196
161
 
197
- The directory defaults to `agent`, where an Eve agent keeps its skills; an
198
- existing copy is kept unless you pass `--force`.
162
+ The directory defaults to `agent`, where an Eve agent keeps its skills; an existing copy is kept unless you pass `--force`.
199
163
 
200
164
  ## Documentation
201
165