@felspar/sdk 0.1.1 → 0.2.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/dist/eve.js ADDED
@@ -0,0 +1,53 @@
1
+ import {
2
+ felsparDecisionEvents,
3
+ felsparGate
4
+ } from "./chunks/chunk-247XZ6IY.js";
5
+ import "./chunks/chunk-IY6A2423.js";
6
+ import "./chunks/chunk-HACK7D24.js";
7
+
8
+ // src/eve.ts
9
+ var felsparMcpUrl = "https://mcp.felspar.ai/mcp";
10
+ var felsparTools = [
11
+ "list_jobs",
12
+ "get_job_requirements",
13
+ "get_job_decision",
14
+ "check_output"
15
+ ];
16
+ var felsparDescription = "Felspar: the company's approved decisions. list_jobs lists the jobs this agent may run with each one's purpose; get_job_requirements says everything a job needs; get_job_decision returns the company's outcome, why, the next step, any escalation, and a receipt; check_output checks text you wrote for that decision against the company's rules.";
17
+ function environment(name) {
18
+ const host = globalThis;
19
+ const value = host.process?.env?.[name];
20
+ return value === void 0 || value === "" ? void 0 : value;
21
+ }
22
+ var localHosts = /* @__PURE__ */ new Set(["localhost", "127.0.0.1", "[::1]"]);
23
+ function endpoint(url) {
24
+ const parsed = new URL(url);
25
+ if (parsed.protocol !== "https:" && !localHosts.has(parsed.hostname)) {
26
+ throw new Error(`Felspar's MCP URL must use HTTPS: ${parsed.origin}`);
27
+ }
28
+ return parsed.href;
29
+ }
30
+ function felsparConnection(options = {}) {
31
+ const url = endpoint(options.url ?? environment("FELSPAR_MCP_URL") ?? felsparMcpUrl);
32
+ return {
33
+ url,
34
+ description: options.description ?? felsparDescription,
35
+ auth: {
36
+ getToken: async () => {
37
+ const token = options.agentKey ?? environment("FELSPAR_AGENT_KEY");
38
+ if (token === void 0 || token === "") {
39
+ throw new Error("Set FELSPAR_AGENT_KEY in .env (Felspar web page \u2192 Workspace \u2192 Agents).");
40
+ }
41
+ return { token };
42
+ }
43
+ },
44
+ protocolVersionDiscovery: false,
45
+ tools: { allow: felsparTools }
46
+ };
47
+ }
48
+ export {
49
+ felsparConnection,
50
+ felsparDecisionEvents,
51
+ felsparGate,
52
+ felsparMcpUrl
53
+ };
@@ -0,0 +1,30 @@
1
+ export declare const emailRecipientFields: readonly ["to", "cc", "bcc", "replyTo", "reply_to"];
2
+ export declare const emailSubjectFields: readonly ["subject"];
3
+ type Input = Record<string, unknown>;
4
+ export interface CaseRules {
5
+ testRecipients?: readonly string[];
6
+ recipientFields?: readonly string[];
7
+ subjectFields?: readonly string[];
8
+ }
9
+ export interface CaseRule {
10
+ recipientFields?: readonly string[];
11
+ subjectFields?: readonly string[];
12
+ entity?: {
13
+ field: string;
14
+ };
15
+ }
16
+ export interface CaseScope {
17
+ rules: CaseRules;
18
+ rule: CaseRule;
19
+ entities: readonly string[];
20
+ }
21
+ export interface Found {
22
+ company?: string | undefined;
23
+ reason?: string;
24
+ missing?: true;
25
+ }
26
+ export declare const foldCase: (text: string) => string;
27
+ export declare const caseKeyOf: (rule: CaseRule) => (text: string) => string;
28
+ export declare const sameField: (names: readonly string[]) => (field: string) => boolean;
29
+ export declare function caseFor(scope: CaseScope, input: Input): Found;
30
+ export {};
@@ -0,0 +1,43 @@
1
+ interface Quoted {
2
+ text: string;
3
+ }
4
+ export interface GateJobDescription {
5
+ job: string;
6
+ release: {
7
+ releaseId: string;
8
+ };
9
+ outcomes: readonly {
10
+ id: string;
11
+ nextStep?: Quoted | null | undefined;
12
+ outputs?: readonly {
13
+ id: string;
14
+ }[] | undefined;
15
+ }[];
16
+ whenUnresolved?: Quoted | null | undefined;
17
+ }
18
+ export type JobDescriber = (releaseId: string, jobId: string) => Promise<GateJobDescription>;
19
+ export declare function felsparJobDescriber(configuration: {
20
+ origin: string;
21
+ agentKey?: string;
22
+ session?: string;
23
+ fetcher?: typeof fetch;
24
+ }): JobDescriber;
25
+ export declare function writesProblem(describe: JobDescriber | undefined, decided: {
26
+ releaseId: string | undefined;
27
+ jobId: string;
28
+ outcome: string;
29
+ output: string;
30
+ }): Promise<string | null>;
31
+ export type EscalationStep = {
32
+ kind: "unresolved";
33
+ releaseId: string | undefined;
34
+ } | {
35
+ kind: "outcome";
36
+ releaseId: string | undefined;
37
+ outcome: string;
38
+ } | {
39
+ kind: "output-check";
40
+ };
41
+ export declare const fixOutputCheck = "Fix what check_output flagged, check it again, then retry.";
42
+ export declare function escalationFor(step: EscalationStep | undefined, describe: JobDescriber | undefined, jobId: string): Promise<string | null>;
43
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { OutputCheckRule } from "./draft-action-gate-outputs.js";
2
+ export interface ActionRule {
3
+ outcomes?: readonly string[];
4
+ writes?: string;
5
+ fields: readonly string[];
6
+ recipientFields?: readonly string[];
7
+ subjectFields?: readonly string[];
8
+ entity?: {
9
+ field: string;
10
+ };
11
+ outputCheck?: OutputCheckRule;
12
+ }
13
+ export declare function ruleProblem(rule: ActionRule): "this tool's rule must give exactly one of outcomes or writes" | "this tool's rule has unreadable outcomes" | "this tool's rule has an unreadable writes" | "this tool's rule has an unreadable entity field" | "this tool's output check is for a different output than it writes" | null;
14
+ export declare function fieldProblem(refuse: readonly string[], rule: ActionRule, input: Record<string, unknown>): string | null;
15
+ export declare function checkRuleOf(rule: ActionRule): OutputCheckRule | undefined;
@@ -1,18 +1,17 @@
1
- import type { FelsparOutputCheck, OutputCheckRule, OutputCheckVerifier } from "./draft-action-gate-outputs.js";
1
+ import type { JobDescriber } from "./draft-action-gate-describe.js";
2
+ import type { FelsparOutputCheck, OutputCheckVerifier } from "./draft-action-gate-outputs.js";
3
+ import type { ActionRule } from "./draft-action-gate-rules.js";
2
4
  import type { DecisionRecorder, FelsparDecision, ReceiptVerifier } from "./draft-action-gate-decisions.js";
5
+ export { emailRecipientFields, emailSubjectFields } from "./draft-action-gate-cases.js";
3
6
  export { createDecisionRecorder, decisionFromResult, entityIdOf, jobOf, } from "./draft-action-gate-decisions.js";
4
7
  export type { DecisionRecorder, DecisionRecorderLimits, FelsparDecision, ReceiptVerifier, VerifiedDecision, } from "./draft-action-gate-decisions.js";
8
+ export { felsparJobDescriber } from "./draft-action-gate-describe.js";
9
+ export type { GateJobDescription, JobDescriber } from "./draft-action-gate-describe.js";
5
10
  export { isCompanyDomain, sharedDomains } from "./draft-action-gate-domains.js";
11
+ export type { ActionRule } from "./draft-action-gate-rules.js";
6
12
  export { felsparVerifier } from "./draft-action-gate-verifier.js";
7
13
  export { felsparOutputCheckVerifier, outputCheckFromResult, outputTextDigest, } from "./draft-action-gate-outputs.js";
8
14
  export type { FelsparOutputCheck, OutputCheckRule, OutputCheckVerifier, } from "./draft-action-gate-outputs.js";
9
- export interface ActionRule {
10
- outcomes: readonly string[];
11
- fields: readonly string[];
12
- recipientFields?: readonly string[];
13
- subjectFields?: readonly string[];
14
- outputCheck?: OutputCheckRule;
15
- }
16
15
  export interface ActionGateRules {
17
16
  job: string;
18
17
  tools: Readonly<Record<string, ActionRule>>;
@@ -30,9 +29,12 @@ export type ActionVerdict = {
30
29
  } | {
31
30
  allow: false;
32
31
  reason: string;
32
+ escalate?: string;
33
33
  };
34
- export declare const emailRecipientFields: readonly ["to", "cc", "bcc", "replyTo", "reply_to"];
35
- export declare const emailSubjectFields: readonly ["subject"];
34
+ export declare function denialText(verdict: {
35
+ reason: string;
36
+ escalate?: string;
37
+ }): string;
36
38
  export declare function gatedRule(rules: ActionGateRules, toolName: string): ActionRule | undefined;
37
39
  export interface CheckActionRequest {
38
40
  rules: ActionGateRules;
@@ -42,6 +44,7 @@ export interface CheckActionRequest {
42
44
  verify: ReceiptVerifier;
43
45
  outputChecks?: readonly FelsparOutputCheck[];
44
46
  verifyOutputCheck?: OutputCheckVerifier;
47
+ describe?: JobDescriber;
45
48
  now?: () => number;
46
49
  }
47
50
  export declare function checkAction(request: CheckActionRequest): Promise<ActionVerdict>;
@@ -50,6 +53,7 @@ export interface ActionGateConfig extends ActionGateRules {
50
53
  decisionTool: string;
51
54
  outputCheckTool?: string;
52
55
  verifyOutputCheck?: OutputCheckVerifier;
56
+ describe?: JobDescriber;
53
57
  decisions?: DecisionRecorder;
54
58
  now?: () => number;
55
59
  onVerdict?: (toolName: string, verdict: ActionVerdict) => void;
@@ -1539,7 +1539,7 @@ export declare function createHostedFelsparClient(configuration: {
1539
1539
  outputSurface: string;
1540
1540
  entries: {
1541
1541
  id: string;
1542
- primitive: "gaps" | "actors" | "decision_criteria" | "source_signals" | "needs_and_requirements" | "evidence_and_proof" | "boundaries" | "output_contracts" | "routing_jobs" | "evaluations";
1542
+ primitive: "gaps" | "actors" | "decision_criteria" | "source_signals" | "needs_and_requirements" | "evidence_and_proof" | "boundaries" | "output_contracts" | "routing_jobs" | "evaluations" | "subjects";
1543
1543
  body: string;
1544
1544
  source: {
1545
1545
  sourceId: string;
@@ -1588,6 +1588,61 @@ export declare function createHostedFelsparClient(configuration: {
1588
1588
  max: number;
1589
1589
  withProgress: number;
1590
1590
  } | undefined;
1591
+ subjects?: {
1592
+ job: string;
1593
+ types: {
1594
+ id: string;
1595
+ entryId: string;
1596
+ match: "exact" | "case-insensitive";
1597
+ relationships: {
1598
+ name: string;
1599
+ subject: string;
1600
+ cardinality: "one" | "many";
1601
+ required: boolean;
1602
+ entryId: string;
1603
+ }[];
1604
+ identifier?: string | undefined;
1605
+ example?: string | undefined;
1606
+ }[];
1607
+ about: {
1608
+ key: string;
1609
+ relationship: string;
1610
+ }[];
1611
+ } | undefined;
1612
+ escalations?: {
1613
+ routes: {
1614
+ id: string;
1615
+ entryId: string;
1616
+ }[];
1617
+ outcomes: {
1618
+ outcome: string;
1619
+ escalation: string;
1620
+ }[];
1621
+ unresolved: string | null;
1622
+ attemptLimit: string | null;
1623
+ } | undefined;
1624
+ guide?: {
1625
+ purpose: string | null;
1626
+ useWhen: string[];
1627
+ notFor: string[];
1628
+ owner: string | null;
1629
+ } | undefined;
1630
+ caseIdentity?: {
1631
+ mode: "provided";
1632
+ } | {
1633
+ mode: "fields";
1634
+ fields: {
1635
+ name: string;
1636
+ identifier: string;
1637
+ example: string;
1638
+ match: "exact" | "case-insensitive";
1639
+ }[];
1640
+ } | {
1641
+ mode: "content";
1642
+ question: string;
1643
+ } | {
1644
+ mode: "issued";
1645
+ } | undefined;
1591
1646
  };
1592
1647
  expectedPlanDigest: string;
1593
1648
  requestedSurface: string;
@@ -2517,7 +2572,7 @@ export declare function createHostedFelsparClient(configuration: {
2517
2572
  outputSurface: string;
2518
2573
  entries: {
2519
2574
  id: string;
2520
- primitive: "gaps" | "actors" | "decision_criteria" | "source_signals" | "needs_and_requirements" | "evidence_and_proof" | "boundaries" | "output_contracts" | "routing_jobs" | "evaluations";
2575
+ primitive: "gaps" | "actors" | "decision_criteria" | "source_signals" | "needs_and_requirements" | "evidence_and_proof" | "boundaries" | "output_contracts" | "routing_jobs" | "evaluations" | "subjects";
2521
2576
  body: string;
2522
2577
  source: {
2523
2578
  sourceId: string;
@@ -2566,6 +2621,61 @@ export declare function createHostedFelsparClient(configuration: {
2566
2621
  max: number;
2567
2622
  withProgress: number;
2568
2623
  } | undefined;
2624
+ subjects?: {
2625
+ job: string;
2626
+ types: {
2627
+ id: string;
2628
+ entryId: string;
2629
+ match: "exact" | "case-insensitive";
2630
+ relationships: {
2631
+ name: string;
2632
+ subject: string;
2633
+ cardinality: "one" | "many";
2634
+ required: boolean;
2635
+ entryId: string;
2636
+ }[];
2637
+ identifier?: string | undefined;
2638
+ example?: string | undefined;
2639
+ }[];
2640
+ about: {
2641
+ key: string;
2642
+ relationship: string;
2643
+ }[];
2644
+ } | undefined;
2645
+ escalations?: {
2646
+ routes: {
2647
+ id: string;
2648
+ entryId: string;
2649
+ }[];
2650
+ outcomes: {
2651
+ outcome: string;
2652
+ escalation: string;
2653
+ }[];
2654
+ unresolved: string | null;
2655
+ attemptLimit: string | null;
2656
+ } | undefined;
2657
+ guide?: {
2658
+ purpose: string | null;
2659
+ useWhen: string[];
2660
+ notFor: string[];
2661
+ owner: string | null;
2662
+ } | undefined;
2663
+ caseIdentity?: {
2664
+ mode: "provided";
2665
+ } | {
2666
+ mode: "fields";
2667
+ fields: {
2668
+ name: string;
2669
+ identifier: string;
2670
+ example: string;
2671
+ match: "exact" | "case-insensitive";
2672
+ }[];
2673
+ } | {
2674
+ mode: "content";
2675
+ question: string;
2676
+ } | {
2677
+ mode: "issued";
2678
+ } | undefined;
2569
2679
  };
2570
2680
  expectedPlanDigest: string;
2571
2681
  requestedSurface: string;
@@ -3171,6 +3281,10 @@ export declare function createHostedFelsparClient(configuration: {
3171
3281
  text: string;
3172
3282
  }[];
3173
3283
  }[] | undefined;
3284
+ about?: {
3285
+ relationship: string;
3286
+ subject: string;
3287
+ } | undefined;
3174
3288
  }[];
3175
3289
  rules: {
3176
3290
  id: string;
@@ -3293,6 +3407,7 @@ export declare function createHostedFelsparClient(configuration: {
3293
3407
  id: string;
3294
3408
  }[] | undefined;
3295
3409
  }[] | undefined;
3410
+ escalate?: string | undefined;
3296
3411
  }[];
3297
3412
  guidance: {
3298
3413
  gather: string;
@@ -3315,6 +3430,7 @@ export declare function createHostedFelsparClient(configuration: {
3315
3430
  locator?: string | undefined;
3316
3431
  sensitivity?: string | undefined;
3317
3432
  };
3433
+ about?: string | undefined;
3318
3434
  } | {
3319
3435
  text: string;
3320
3436
  source: {
@@ -3325,6 +3441,7 @@ export declare function createHostedFelsparClient(configuration: {
3325
3441
  locator?: string | undefined;
3326
3442
  sensitivity?: string | undefined;
3327
3443
  };
3444
+ about?: string | undefined;
3328
3445
  }[] | {
3329
3446
  value: string | number | boolean;
3330
3447
  source: {
@@ -3336,7 +3453,10 @@ export declare function createHostedFelsparClient(configuration: {
3336
3453
  sensitivity?: string | undefined;
3337
3454
  excerpt?: string | undefined;
3338
3455
  };
3456
+ about?: string | undefined;
3339
3457
  }>;
3458
+ related?: Record<string, string | string[]> | undefined;
3459
+ identity?: Record<string, string> | undefined;
3340
3460
  } | null;
3341
3461
  exampleNote: string;
3342
3462
  };
@@ -3350,6 +3470,145 @@ export declare function createHostedFelsparClient(configuration: {
3350
3470
  maxQuestions: 64;
3351
3471
  };
3352
3472
  };
3473
+ purpose?: {
3474
+ text: string;
3475
+ source: {
3476
+ sourceId: string;
3477
+ revision: string;
3478
+ locator: string;
3479
+ contentDigest: string;
3480
+ };
3481
+ parts: {
3482
+ locator: string;
3483
+ text: string;
3484
+ }[];
3485
+ } | undefined;
3486
+ useWhen?: {
3487
+ text: string;
3488
+ source: {
3489
+ sourceId: string;
3490
+ revision: string;
3491
+ locator: string;
3492
+ contentDigest: string;
3493
+ };
3494
+ parts: {
3495
+ locator: string;
3496
+ text: string;
3497
+ }[];
3498
+ }[] | undefined;
3499
+ notFor?: {
3500
+ text: string;
3501
+ source: {
3502
+ sourceId: string;
3503
+ revision: string;
3504
+ locator: string;
3505
+ contentDigest: string;
3506
+ };
3507
+ parts: {
3508
+ locator: string;
3509
+ text: string;
3510
+ }[];
3511
+ }[] | undefined;
3512
+ owner?: {
3513
+ text: string;
3514
+ source: {
3515
+ sourceId: string;
3516
+ revision: string;
3517
+ locator: string;
3518
+ contentDigest: string;
3519
+ };
3520
+ parts: {
3521
+ locator: string;
3522
+ text: string;
3523
+ }[];
3524
+ } | undefined;
3525
+ subject?: {
3526
+ type: string;
3527
+ definition: {
3528
+ text: string;
3529
+ source: {
3530
+ sourceId: string;
3531
+ revision: string;
3532
+ locator: string;
3533
+ contentDigest: string;
3534
+ };
3535
+ parts: {
3536
+ locator: string;
3537
+ text: string;
3538
+ }[];
3539
+ };
3540
+ match: "exact" | "case-insensitive";
3541
+ related: {
3542
+ identifier: string;
3543
+ example: string;
3544
+ match: "exact" | "case-insensitive";
3545
+ relationship: string;
3546
+ meaning: {
3547
+ text: string;
3548
+ source: {
3549
+ sourceId: string;
3550
+ revision: string;
3551
+ locator: string;
3552
+ contentDigest: string;
3553
+ };
3554
+ parts: {
3555
+ locator: string;
3556
+ text: string;
3557
+ }[];
3558
+ };
3559
+ cardinality: "one" | "many";
3560
+ required: boolean;
3561
+ subject: string;
3562
+ definition: {
3563
+ text: string;
3564
+ source: {
3565
+ sourceId: string;
3566
+ revision: string;
3567
+ locator: string;
3568
+ contentDigest: string;
3569
+ };
3570
+ parts: {
3571
+ locator: string;
3572
+ text: string;
3573
+ }[];
3574
+ };
3575
+ }[];
3576
+ send: string;
3577
+ identifier?: string | undefined;
3578
+ example?: string | undefined;
3579
+ } | undefined;
3580
+ identity?: {
3581
+ mode: "provided" | "fields" | "content" | "issued";
3582
+ send: string;
3583
+ fields?: {
3584
+ identifier: string;
3585
+ example: string;
3586
+ match: "exact" | "case-insensitive";
3587
+ name: string;
3588
+ }[] | undefined;
3589
+ question?: string | undefined;
3590
+ } | undefined;
3591
+ escalations?: {
3592
+ routes: {
3593
+ id: string;
3594
+ quote: {
3595
+ text: string;
3596
+ source: {
3597
+ sourceId: string;
3598
+ revision: string;
3599
+ locator: string;
3600
+ contentDigest: string;
3601
+ };
3602
+ parts: {
3603
+ locator: string;
3604
+ text: string;
3605
+ }[];
3606
+ };
3607
+ }[];
3608
+ unresolved: string | null;
3609
+ attemptLimit: string | null;
3610
+ rule: string;
3611
+ } | undefined;
3353
3612
  whenUnresolved?: {
3354
3613
  text: string;
3355
3614
  source: {
@@ -3378,6 +3637,23 @@ export declare function createHostedFelsparClient(configuration: {
3378
3637
  entityId: string;
3379
3638
  releaseId: string;
3380
3639
  outcome: string | null;
3640
+ case?: {
3641
+ id: string;
3642
+ mode: "provided" | "fields" | "content" | "issued";
3643
+ } | undefined;
3644
+ subject?: {
3645
+ type: string;
3646
+ related: {
3647
+ relationship: string;
3648
+ subject: string;
3649
+ id: string;
3650
+ questions: string[];
3651
+ }[];
3652
+ } | undefined;
3653
+ escalation?: {
3654
+ id: string;
3655
+ trigger: "outcome" | "unresolved" | "attempt_limit";
3656
+ } | undefined;
3381
3657
  } | undefined;
3382
3658
  }>;
3383
3659
  };
@@ -0,0 +1,22 @@
1
+ export { felsparDecisionEvents, felsparGate } from "./draft-action-gate-eve.js";
2
+ export type { EveApprovalStatus } from "./draft-action-gate-eve.js";
3
+ export declare const felsparMcpUrl = "https://mcp.felspar.ai/mcp";
4
+ export interface FelsparConnectionOptions {
5
+ url?: string;
6
+ agentKey?: string;
7
+ description?: string;
8
+ }
9
+ export interface FelsparConnection {
10
+ url: string;
11
+ description: string;
12
+ auth: {
13
+ getToken: () => Promise<{
14
+ token: string;
15
+ }>;
16
+ };
17
+ protocolVersionDiscovery: false;
18
+ tools: {
19
+ allow: readonly string[];
20
+ };
21
+ }
22
+ export declare function felsparConnection(options?: FelsparConnectionOptions): FelsparConnection;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@felspar/sdk",
3
- "version": "0.1.1",
3
+ "version": "0.2.0",
4
4
  "description": "Client and action gate for Felspar, the shared decision system for enterprise agents.",
5
5
  "license": "Apache-2.0",
6
6
  "homepage": "https://docs.felspar.ai",
@@ -24,6 +24,10 @@
24
24
  ],
25
25
  "type": "module",
26
26
  "exports": {
27
+ "./eve": {
28
+ "types": "./dist/types/eve.d.ts",
29
+ "default": "./dist/eve.js"
30
+ },
27
31
  "./draft/hosted-client": {
28
32
  "types": "./dist/types/draft-hosted-client.d.ts",
29
33
  "default": "./dist/draft-hosted-client.js"
@@ -46,8 +50,13 @@
46
50
  },
47
51
  "./package.json": "./package.json"
48
52
  },
53
+ "bin": {
54
+ "felspar-sdk": "bin/felspar-sdk.mjs"
55
+ },
49
56
  "files": [
50
57
  "dist",
58
+ "bin",
59
+ "skills/felspar/SKILL.md",
51
60
  "README.md",
52
61
  "LICENSE"
53
62
  ],