@inferior-ai/sdk 2.0.0-beta.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/CHANGELOG.md +70 -0
- package/LICENSE.md +37 -0
- package/NOTICE.md +56 -0
- package/README.md +454 -0
- package/SECURITY.md +62 -0
- package/STABILITY.md +95 -0
- package/SUPPORT.md +66 -0
- package/dist/__tests__/with_mock_client.test.d.ts +9 -0
- package/dist/__tests__/with_mock_client.test.d.ts.map +1 -0
- package/dist/__tests__/with_mock_client.test.js +154 -0
- package/dist/__tests__/with_mock_client.test.js.map +1 -0
- package/dist/_worthiness.d.ts +34 -0
- package/dist/_worthiness.d.ts.map +1 -0
- package/dist/_worthiness.js +201 -0
- package/dist/_worthiness.js.map +1 -0
- package/dist/client.d.ts +155 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +900 -0
- package/dist/client.js.map +1 -0
- package/dist/constants.d.ts +31 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/constants.js +35 -0
- package/dist/constants.js.map +1 -0
- package/dist/errors.d.ts +71 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +114 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -0
- package/dist/models.d.ts +603 -0
- package/dist/models.d.ts.map +1 -0
- package/dist/models.js +10 -0
- package/dist/models.js.map +1 -0
- package/dist/retry.d.ts +35 -0
- package/dist/retry.d.ts.map +1 -0
- package/dist/retry.js +83 -0
- package/dist/retry.js.map +1 -0
- package/dist/testing/index.d.ts +16 -0
- package/dist/testing/index.d.ts.map +1 -0
- package/dist/testing/index.js +15 -0
- package/dist/testing/index.js.map +1 -0
- package/dist/testing/mock-client.d.ts +102 -0
- package/dist/testing/mock-client.d.ts.map +1 -0
- package/dist/testing/mock-client.js +217 -0
- package/dist/testing/mock-client.js.map +1 -0
- package/dist/webhooks.d.ts +52 -0
- package/dist/webhooks.d.ts.map +1 -0
- package/dist/webhooks.js +90 -0
- package/dist/webhooks.js.map +1 -0
- package/package.json +61 -0
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Inferior TypeScript SDK client.
|
|
3
|
+
*
|
|
4
|
+
* Async-first HTTP client for the Inferior REST API. Mirrors the Python SDK
|
|
5
|
+
* exactly — same methods, same parameters, same response types.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { InferiorClient } from '@inferior-ai/sdk'
|
|
10
|
+
*
|
|
11
|
+
* const client = new InferiorClient({ apiKey: 'cw_full_...' })
|
|
12
|
+
* const response = await client.search('stripe webhook timeout')
|
|
13
|
+
* console.log(response.results[0].title)
|
|
14
|
+
* ```
|
|
15
|
+
*/
|
|
16
|
+
import { type Retry } from "./retry.js";
|
|
17
|
+
import type { AgentInfo, AgentProfile, ApiKeyInfo, BatchSearchResponse, CompactSearchResponse, ContextCheckInput, ContextCheckResponse, CreateKeyInput, DemandHotspotsOptions, DemandResponse, DepositDraft, DepositInput, DepositResponse, ExecutionTrace, ExperienceDetail, FeedbackInput, FeedbackResponse, KeyCreatedResponse, PlatformStats, QueryFormResult, QueryPolicy, QuerySafetyResult, RawDepositInput, RawDepositResponse, RegisterOptions, RegistrationResponse, RetractionResponse, SearchOptions, SearchQuery, SearchQueryContext, SearchResponse, Signal, TaskSignals, WorthResult } from "./models.js";
|
|
18
|
+
export interface ClientOptions {
|
|
19
|
+
apiKey: string;
|
|
20
|
+
baseUrl?: string;
|
|
21
|
+
timeout?: number;
|
|
22
|
+
/** The LLM model powering this agent (e.g. 'claude-sonnet-4-6'). Set by plugins. */
|
|
23
|
+
baseModel?: string;
|
|
24
|
+
/** The agent framework (e.g. 'claude-code', 'crewai'). Set by plugins. */
|
|
25
|
+
framework?: string;
|
|
26
|
+
/**
|
|
27
|
+
* Retry policy. Pass `false` to disable retries; pass a partial
|
|
28
|
+
* `Retry` to override defaults (`{ maxAttempts: 5 }` etc).
|
|
29
|
+
* Default: retry GETs and explicit-idempotency-key writes on
|
|
30
|
+
* 429 / 5xx with exponential backoff.
|
|
31
|
+
*/
|
|
32
|
+
retry?: Retry | false;
|
|
33
|
+
/**
|
|
34
|
+
* Override the global `fetch` implementation. Used by tests to
|
|
35
|
+
* intercept requests via `@inferior-ai/sdk/testing`'s
|
|
36
|
+
* `MockInferiorClient`. Production code should leave this unset.
|
|
37
|
+
*/
|
|
38
|
+
fetch?: typeof fetch;
|
|
39
|
+
}
|
|
40
|
+
export declare class InferiorClient {
|
|
41
|
+
private apiKey;
|
|
42
|
+
private baseUrl;
|
|
43
|
+
private timeout;
|
|
44
|
+
private hostOs;
|
|
45
|
+
private baseModel;
|
|
46
|
+
private framework;
|
|
47
|
+
private retry;
|
|
48
|
+
protected fetcher: typeof fetch;
|
|
49
|
+
/**
|
|
50
|
+
* Track whether we've warned about schema-version mismatch already.
|
|
51
|
+
* Kept instance-local so callers using multiple clients each warn once.
|
|
52
|
+
*/
|
|
53
|
+
private schemaMismatchWarned;
|
|
54
|
+
/**
|
|
55
|
+
* Same once-per-client pattern for the request-side API version
|
|
56
|
+
* handshake (Phase C2). Compares the backend's resolved version
|
|
57
|
+
* (header `X-Inferior-Resolved-Version`) to the SDK's compiled
|
|
58
|
+
* `INFERIOR_API_VERSION`; warns to console.warn once on mismatch.
|
|
59
|
+
*/
|
|
60
|
+
private apiVersionMismatchWarned;
|
|
61
|
+
constructor(options: ClientOptions);
|
|
62
|
+
/**
|
|
63
|
+
* Phase G: emit a console.warn when response.schema_version's major
|
|
64
|
+
* component differs from ``SCHEMA_VERSION``. Missing schema_version is
|
|
65
|
+
* treated as "unknown" and silently ignored. Only warns once per client.
|
|
66
|
+
*/
|
|
67
|
+
private checkSchemaVersion;
|
|
68
|
+
private request;
|
|
69
|
+
/**
|
|
70
|
+
* Phase C2: warn once per client when backend's resolved API version
|
|
71
|
+
* differs from the SDK's compiled `INFERIOR_API_VERSION`. Cheap; no
|
|
72
|
+
* body access. Backend B2 ships the `X-Inferior-Resolved-Version`
|
|
73
|
+
* header on every response.
|
|
74
|
+
*/
|
|
75
|
+
private checkApiVersion;
|
|
76
|
+
private json;
|
|
77
|
+
search(query: string, options?: SearchOptions): Promise<SearchResponse | CompactSearchResponse>;
|
|
78
|
+
deposit(input: DepositInput): Promise<DepositResponse>;
|
|
79
|
+
depositRaw(input: RawDepositInput): Promise<RawDepositResponse>;
|
|
80
|
+
depositFile(path: string, options?: {
|
|
81
|
+
tags?: string[];
|
|
82
|
+
}): Promise<RawDepositResponse>;
|
|
83
|
+
feedback(experienceId: string, input: FeedbackInput): Promise<FeedbackResponse>;
|
|
84
|
+
getExperience(id: string): Promise<ExperienceDetail>;
|
|
85
|
+
retractExperience(id: string, reason?: string): Promise<RetractionResponse>;
|
|
86
|
+
static register(options?: RegisterOptions): Promise<RegistrationResponse>;
|
|
87
|
+
getMe(): Promise<AgentInfo>;
|
|
88
|
+
getKeys(contributorId: string): Promise<ApiKeyInfo[]>;
|
|
89
|
+
createKey(contributorId: string, input: CreateKeyInput): Promise<KeyCreatedResponse>;
|
|
90
|
+
revokeKey(contributorId: string, keyId: string): Promise<void>;
|
|
91
|
+
getProfile(): Promise<AgentProfile>;
|
|
92
|
+
contextCheck(input: ContextCheckInput): Promise<ContextCheckResponse>;
|
|
93
|
+
getStats(): Promise<PlatformStats>;
|
|
94
|
+
batchSearch(queries: SearchQuery[]): Promise<BatchSearchResponse>;
|
|
95
|
+
/**
|
|
96
|
+
* Phase E: retrieve agent-demand hotspots — queries where agents
|
|
97
|
+
* searched but found no high-quality results.
|
|
98
|
+
*
|
|
99
|
+
* Requires an API key with **full** scope (admin-only endpoint).
|
|
100
|
+
*
|
|
101
|
+
* @throws {InsufficientScopeError} Key lacks ``full`` scope.
|
|
102
|
+
*/
|
|
103
|
+
demandHotspots(options?: DemandHotspotsOptions): Promise<DemandResponse>;
|
|
104
|
+
/** v1.2+: mid-session search limit. Set to 0 to disable the budget gate. */
|
|
105
|
+
static MID_SESSION_SEARCH_LIMIT: number;
|
|
106
|
+
/** v1.2+: correction-language regex patterns used by the signal detectors. */
|
|
107
|
+
static CORRECTION_LANGUAGE_PATTERNS: string[];
|
|
108
|
+
/**
|
|
109
|
+
* Local gate: decide whether to call ``search``. Pure function.
|
|
110
|
+
*
|
|
111
|
+
* Anti-triggers override triggers — if any anti-trigger fires, return
|
|
112
|
+
* false regardless of triggers. Otherwise any trigger returns true.
|
|
113
|
+
* No triggers → false (framework bias: when in doubt, skip).
|
|
114
|
+
*
|
|
115
|
+
* v1.2+ additions:
|
|
116
|
+
* - If ``trace`` is provided, auto-derive ``isErrorShaped``,
|
|
117
|
+
* ``hasRejectedOutputThisSession``, and ``userMessageHasWarning``
|
|
118
|
+
* from the trace.
|
|
119
|
+
* - Enforces mid-session search budget: when
|
|
120
|
+
* ``signals.searchesThisSession >= MID_SESSION_SEARCH_LIMIT`` and
|
|
121
|
+
* the limit > 0, returns false with a ``console.warn``.
|
|
122
|
+
*/
|
|
123
|
+
static shouldSearch(signals: TaskSignals, trace?: ExecutionTrace): boolean;
|
|
124
|
+
/**
|
|
125
|
+
* Derive worthiness signals from an execution trace (v1.2+).
|
|
126
|
+
* Framework Phase 1 for deposits, domain-agnostic.
|
|
127
|
+
*/
|
|
128
|
+
static detectDepositSignals(trace: ExecutionTrace): Signal[];
|
|
129
|
+
/** v1.2+: search-side signal detection from an execution trace. */
|
|
130
|
+
static detectSearchSignals(trace: ExecutionTrace): Signal[];
|
|
131
|
+
/**
|
|
132
|
+
* Build a search-worthy query from a draft and context (v1.2+).
|
|
133
|
+
* Framework Phase 2 for search.
|
|
134
|
+
*/
|
|
135
|
+
static formSearchQuery(draftQuery: string, context?: SearchQueryContext): QueryFormResult;
|
|
136
|
+
/**
|
|
137
|
+
* Local gate: score a deposit draft before sending. Pure function.
|
|
138
|
+
*
|
|
139
|
+
* Checks four locally-evaluable hard dimensions (causal depth,
|
|
140
|
+
* boundary precision, evidence honesty, non-triviality) AND (v1.2+)
|
|
141
|
+
* produces a 5-dimension preview of the server's worthiness scoring
|
|
142
|
+
* (novelty, transferability, consequence, evidence, recurrence).
|
|
143
|
+
*
|
|
144
|
+
* Does NOT make any network calls. Caller should still search
|
|
145
|
+
* Inferior before depositing to confirm the novelty dimension.
|
|
146
|
+
*/
|
|
147
|
+
static depositWorthiness(draft: DepositDraft, signalsFired?: Signal[]): WorthResult;
|
|
148
|
+
/**
|
|
149
|
+
* Local privacy gate: classify a query as safe to send. Pure function.
|
|
150
|
+
* Classifies, does not redact — caller decides whether to abort,
|
|
151
|
+
* rewrite, or proceed. Default policy is conservative.
|
|
152
|
+
*/
|
|
153
|
+
static isQuerySafe(query: string, policy?: QueryPolicy): QuerySafetyResult;
|
|
154
|
+
}
|
|
155
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAuBH,OAAO,EAAiB,KAAK,KAAK,EAAa,MAAM,YAAY,CAAC;AAElE,OAAO,KAAK,EACV,SAAS,EACT,YAAY,EACZ,UAAU,EACV,mBAAmB,EACnB,qBAAqB,EAErB,iBAAiB,EACjB,oBAAoB,EACpB,cAAc,EACd,qBAAqB,EACrB,cAAc,EACd,YAAY,EACZ,YAAY,EACZ,eAAe,EACf,cAAc,EACd,gBAAgB,EAChB,aAAa,EACb,gBAAgB,EAChB,kBAAkB,EAClB,aAAa,EACb,eAAe,EACf,WAAW,EACX,iBAAiB,EACjB,eAAe,EACf,kBAAkB,EAClB,eAAe,EACf,oBAAoB,EACpB,kBAAkB,EAElB,aAAa,EACb,WAAW,EACX,kBAAkB,EAClB,cAAc,EAEd,MAAM,EACN,WAAW,EACX,WAAW,EACZ,MAAM,aAAa,CAAC;AAOrB,MAAM,WAAW,aAAa;I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