@synapseone/sdk 0.0.0-stage → 0.7.0-dev.41

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/iam.d.ts ADDED
@@ -0,0 +1,88 @@
1
+ import { HttpClient } from './_http';
2
+ export declare class IamService {
3
+ private readonly http;
4
+ constructor(http: HttpClient);
5
+ login(email: string, orgSlug?: string): Promise<{
6
+ accessToken: string;
7
+ refreshToken: string;
8
+ user: any;
9
+ }>;
10
+ refresh(refreshToken: string): Promise<{
11
+ accessToken: string;
12
+ refreshToken: string;
13
+ }>;
14
+ logout(refreshToken: string): Promise<unknown>;
15
+ logoutAll(refreshToken: string): Promise<{
16
+ ok: boolean;
17
+ revoked: number;
18
+ }>;
19
+ verify(): Promise<unknown>;
20
+ me(): Promise<unknown>;
21
+ oidcConfig(): Promise<unknown>;
22
+ oidcStart(org?: string): Promise<unknown>;
23
+ oidcCallback(code: string, state: string): Promise<{
24
+ accessToken: string;
25
+ refreshToken: string;
26
+ user: any;
27
+ }>;
28
+ listOrgs(): Promise<any[]>;
29
+ createOrg(slug: string, displayName: string): Promise<unknown>;
30
+ listAccounts(orgId: string): Promise<unknown>;
31
+ listUsers(orgId: string): Promise<unknown>;
32
+ createUser(orgId: string, email: string, displayName?: string): Promise<unknown>;
33
+ createAccount(orgId: string, slug: string, displayName: string): Promise<unknown>;
34
+ userPolicies(userId: string): Promise<unknown>;
35
+ createRole(accountId: string, slug: string, description?: string): Promise<unknown>;
36
+ listRoles(accountId: string): Promise<unknown>;
37
+ deleteRole(roleId: string): Promise<unknown>;
38
+ listPolicies(accountId: string): Promise<unknown>;
39
+ deletePolicy(policyId: string): Promise<unknown>;
40
+ createPolicy(accountId: string, slug: string, document: any, description?: string): Promise<unknown>;
41
+ authorize(userId: string, action: string, resource: string, context?: Record<string, unknown>): Promise<{
42
+ allowed: boolean;
43
+ }>;
44
+ attachPolicy(roleId: string, policyId: string): Promise<unknown>;
45
+ detachPolicy(roleId: string, policyId: string): Promise<unknown>;
46
+ rolePolicies(roleId: string): Promise<unknown>;
47
+ assignRole(userId: string, roleId: string): Promise<unknown>;
48
+ unassignRole(userId: string, roleId: string): Promise<unknown>;
49
+ userRoles(userId: string): Promise<unknown>;
50
+ simulate(documents: any[], action: string, resource: string, context?: Record<string, unknown>): Promise<{
51
+ allowed: boolean;
52
+ }>;
53
+ listAudit(limit?: number, actor?: string): Promise<unknown>;
54
+ createApiKey(accountId: string, name?: string, scopes?: string[]): Promise<{
55
+ apiKey: string;
56
+ }>;
57
+ revokeApiKey(keyId: string): Promise<unknown>;
58
+ listApiKeys(accountId: string): Promise<unknown>;
59
+ verifyApiKey(apiKey: string): Promise<unknown>;
60
+ createServiceAccount(accountId: string, slug: string, description?: string): Promise<unknown>;
61
+ listServiceAccounts(accountId: string): Promise<unknown>;
62
+ serviceAccountToken(saId: string, scopes?: string[]): Promise<{
63
+ accessToken: string;
64
+ }>;
65
+ usageSummary(filter?: {
66
+ from?: string | Date;
67
+ to?: string | Date;
68
+ feature?: string;
69
+ accountId?: string;
70
+ actor?: string;
71
+ method?: string;
72
+ status?: number;
73
+ statusClass?: string;
74
+ }): Promise<any>;
75
+ usageEvents(filter?: {
76
+ from?: string | Date;
77
+ to?: string | Date;
78
+ feature?: string;
79
+ accountId?: string;
80
+ actor?: string;
81
+ method?: string;
82
+ status?: number;
83
+ statusClass?: string;
84
+ q?: string;
85
+ limit?: number;
86
+ offset?: number;
87
+ }): Promise<any>;
88
+ }
package/dist/iam.js ADDED
@@ -0,0 +1,149 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2026 SynapseOne Contributors
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * Synapse IAM client: auth/OIDC, orgs/accounts/users, roles/policies,
6
+ * API keys, service accounts and usage analytics.
7
+ *
8
+ * Access it through `new SynapseOneClient(...).iam` or build it with an
9
+ * HttpClient directly.
10
+ */
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.IamService = void 0;
13
+ class IamService {
14
+ http;
15
+ constructor(http) {
16
+ this.http = http;
17
+ }
18
+ // ---- auth ----
19
+ login(email, orgSlug = 'acme') {
20
+ return this.http.req('/v1/auth/login', {
21
+ method: 'POST', body: JSON.stringify({ email, orgSlug }),
22
+ });
23
+ }
24
+ refresh(refreshToken) {
25
+ return this.http.req('/v1/auth/refresh', {
26
+ method: 'POST', body: JSON.stringify({ refreshToken }),
27
+ });
28
+ }
29
+ logout(refreshToken) {
30
+ return this.http.req('/v1/auth/logout', { method: 'POST', body: JSON.stringify({ refreshToken }) });
31
+ }
32
+ logoutAll(refreshToken) {
33
+ return this.http.req('/v1/auth/logout-all', { method: 'POST', body: JSON.stringify({ refreshToken }) });
34
+ }
35
+ verify() { return this.http.req('/v1/auth/verify'); }
36
+ me() { return this.http.req('/v1/auth/me'); }
37
+ oidcConfig() { return this.http.req('/v1/auth/oidc/config'); }
38
+ oidcStart(org = 'acme') { return this.http.req(`/v1/auth/oidc/start?org=${encodeURIComponent(org)}`); }
39
+ oidcCallback(code, state) {
40
+ return this.http.req('/v1/auth/oidc/callback', {
41
+ method: 'POST', body: JSON.stringify({ code, state }),
42
+ });
43
+ }
44
+ // ---- orgs/accounts/users ----
45
+ listOrgs() { return this.http.req('/v1/orgs'); }
46
+ createOrg(slug, displayName) {
47
+ return this.http.req('/v1/orgs', { method: 'POST', body: JSON.stringify({ slug, displayName }) });
48
+ }
49
+ listAccounts(orgId) { return this.http.req(`/v1/orgs/${encodeURIComponent(orgId)}/accounts`); }
50
+ listUsers(orgId) { return this.http.req(`/v1/orgs/${encodeURIComponent(orgId)}/users`); }
51
+ createUser(orgId, email, displayName) {
52
+ return this.http.req(`/v1/orgs/${encodeURIComponent(orgId)}/users`, { method: 'POST', body: JSON.stringify({ email, displayName }) });
53
+ }
54
+ createAccount(orgId, slug, displayName) {
55
+ return this.http.req(`/v1/orgs/${encodeURIComponent(orgId)}/accounts`, { method: 'POST', body: JSON.stringify({ slug, displayName }) });
56
+ }
57
+ userPolicies(userId) { return this.http.req(`/v1/users/${encodeURIComponent(userId)}/policies`); }
58
+ // ---- roles / policies ----
59
+ createRole(accountId, slug, description = '') {
60
+ return this.http.req(`/v1/accounts/${encodeURIComponent(accountId)}/roles`, { method: 'POST', body: JSON.stringify({ slug, description }) });
61
+ }
62
+ listRoles(accountId) { return this.http.req(`/v1/accounts/${encodeURIComponent(accountId)}/roles`); }
63
+ deleteRole(roleId) { return this.http.req(`/v1/roles/${encodeURIComponent(roleId)}`, { method: 'DELETE' }); }
64
+ listPolicies(accountId) { return this.http.req(`/v1/accounts/${encodeURIComponent(accountId)}/policies`); }
65
+ deletePolicy(policyId) { return this.http.req(`/v1/policies/${encodeURIComponent(policyId)}`, { method: 'DELETE' }); }
66
+ createPolicy(accountId, slug, document, description = '') {
67
+ return this.http.req(`/v1/accounts/${encodeURIComponent(accountId)}/policies`, { method: 'POST', body: JSON.stringify({ slug, document, description }) });
68
+ }
69
+ authorize(userId, action, resource, context) {
70
+ return this.http.req('/v1/authorize', { method: 'POST', body: JSON.stringify({ userId, action, resource, context }) });
71
+ }
72
+ attachPolicy(roleId, policyId) {
73
+ return this.http.req(`/v1/roles/${encodeURIComponent(roleId)}/attach`, { method: 'POST', body: JSON.stringify({ policyId }) });
74
+ }
75
+ detachPolicy(roleId, policyId) {
76
+ return this.http.req(`/v1/roles/${encodeURIComponent(roleId)}/policies/${encodeURIComponent(policyId)}`, { method: 'DELETE' });
77
+ }
78
+ rolePolicies(roleId) {
79
+ return this.http.req(`/v1/roles/${encodeURIComponent(roleId)}/policies`);
80
+ }
81
+ assignRole(userId, roleId) {
82
+ return this.http.req(`/v1/users/${encodeURIComponent(userId)}/assign`, { method: 'POST', body: JSON.stringify({ roleId }) });
83
+ }
84
+ unassignRole(userId, roleId) {
85
+ return this.http.req(`/v1/users/${encodeURIComponent(userId)}/roles/${encodeURIComponent(roleId)}`, { method: 'DELETE' });
86
+ }
87
+ userRoles(userId) {
88
+ return this.http.req(`/v1/users/${encodeURIComponent(userId)}/roles`);
89
+ }
90
+ simulate(documents, action, resource, context) {
91
+ return this.http.req('/v1/authorize/dry-run', { method: 'POST', body: JSON.stringify({ documents, action, resource, context }) });
92
+ }
93
+ listAudit(limit = 50, actor) {
94
+ const qs = `?limit=${limit}${actor ? `&actor=${encodeURIComponent(actor)}` : ''}`;
95
+ return this.http.req(`/v1/audit${qs}`);
96
+ }
97
+ // ---- API keys ----
98
+ createApiKey(accountId, name = 'default', scopes = ['*']) {
99
+ return this.http.req(`/v1/accounts/${encodeURIComponent(accountId)}/keys`, { method: 'POST', body: JSON.stringify({ name, scopes }) });
100
+ }
101
+ revokeApiKey(keyId) {
102
+ return this.http.req(`/v1/keys/${encodeURIComponent(keyId)}`, { method: 'DELETE' });
103
+ }
104
+ listApiKeys(accountId) {
105
+ return this.http.req(`/v1/accounts/${encodeURIComponent(accountId)}/keys`);
106
+ }
107
+ verifyApiKey(apiKey) {
108
+ return this.http.req(`/v1/keys/verify`, { method: 'POST', body: JSON.stringify({ apiKey }) });
109
+ }
110
+ // ---- service accounts ----
111
+ createServiceAccount(accountId, slug, description = '') {
112
+ return this.http.req(`/v1/accounts/${encodeURIComponent(accountId)}/service-accounts`, { method: 'POST', body: JSON.stringify({ slug, description }) });
113
+ }
114
+ listServiceAccounts(accountId) { return this.http.req(`/v1/accounts/${encodeURIComponent(accountId)}/service-accounts`); }
115
+ // scopes omitted -> the server delegates the caller's own scopes (never
116
+ // widens to '*'). Pass an explicit list to narrow the minted token.
117
+ serviceAccountToken(saId, scopes) {
118
+ return this.http.req(`/v1/service-accounts/${encodeURIComponent(saId)}/token`, {
119
+ method: 'POST',
120
+ body: JSON.stringify(scopes === undefined ? {} : { scopes }),
121
+ });
122
+ }
123
+ // ---- usage & telemetry ----
124
+ usageSummary(filter) {
125
+ const qs = new URLSearchParams();
126
+ if (filter) {
127
+ for (const [k, v] of Object.entries(filter)) {
128
+ if (v !== undefined && v !== null && String(v) !== '') {
129
+ qs.set(k, v instanceof Date ? v.toISOString() : String(v));
130
+ }
131
+ }
132
+ }
133
+ const s = qs.toString();
134
+ return this.http.req(`/v1/usage/summary${s ? `?${s}` : ''}`);
135
+ }
136
+ usageEvents(filter) {
137
+ const qs = new URLSearchParams();
138
+ if (filter) {
139
+ for (const [k, v] of Object.entries(filter)) {
140
+ if (v !== undefined && v !== null && String(v) !== '') {
141
+ qs.set(k, v instanceof Date ? v.toISOString() : String(v));
142
+ }
143
+ }
144
+ }
145
+ const s = qs.toString();
146
+ return this.http.req(`/v1/usage/events${s ? `?${s}` : ''}`);
147
+ }
148
+ }
149
+ exports.IamService = IamService;
@@ -0,0 +1,66 @@
1
+ import { HttpClient, SynapseOneClientOptions } from './_http';
2
+ import { IamService } from './iam';
3
+ import { WorkflowService } from './workflow';
4
+ import { LdsAttributeInput, LdsDatasourceInput, LdsEntitiesQuery, LdsIngestResult, LdsService } from './lds';
5
+ import { BaseService } from './base';
6
+ import { FaststoreService } from './faststore';
7
+ import { QueueService } from './queue';
8
+ import { StreamService } from './stream';
9
+ import { InferenceService } from './inference';
10
+ import { AiService } from './ai';
11
+ export * from './_http';
12
+ export * from './iam';
13
+ export * from './workflow';
14
+ export * from './ai';
15
+ export * from './lds';
16
+ export * from './base';
17
+ export * from './faststore';
18
+ export * from './queue';
19
+ export * from './stream';
20
+ export * from './inference';
21
+ /** Legacy flat LDS signatures (the namespaced service drops the `lds` prefix). */
22
+ export interface LdsLegacyMethods {
23
+ ldsLicenses(): Promise<any[]>;
24
+ ldsDatasources(query?: {
25
+ orgId?: string;
26
+ accountId?: string;
27
+ }): Promise<any[]>;
28
+ ldsCreateDatasource(input: LdsDatasourceInput): Promise<any>;
29
+ ldsDatasource(id: string): Promise<any>;
30
+ ldsUpdateDatasource(id: string, patch: Partial<LdsDatasourceInput>): Promise<any>;
31
+ ldsDeleteDatasource(id: string): Promise<{
32
+ ok: boolean;
33
+ }>;
34
+ ldsAttributes(id: string): Promise<any[]>;
35
+ ldsSetAttributes(id: string, attributes: LdsAttributeInput[]): Promise<any[]>;
36
+ ldsIngest(id: string, records: Record<string, unknown> | Record<string, unknown>[]): Promise<LdsIngestResult>;
37
+ ldsEntities(id: string, query?: LdsEntitiesQuery): Promise<any[]>;
38
+ ldsEntity(id: string, entityId: string): Promise<any>;
39
+ ldsStats(id: string): Promise<any>;
40
+ }
41
+ export declare class SynapseOneClient {
42
+ readonly http: HttpClient;
43
+ readonly iam: IamService;
44
+ readonly workflow: WorkflowService;
45
+ readonly ai: AiService;
46
+ readonly lds: LdsService;
47
+ readonly base: BaseService;
48
+ readonly faststore: FaststoreService;
49
+ readonly queue: QueueService;
50
+ readonly stream: StreamService;
51
+ readonly inference: InferenceService;
52
+ constructor(opts: SynapseOneClientOptions);
53
+ get baseUrl(): string;
54
+ setToken(t: string): void;
55
+ setApiKey(k: string): void;
56
+ setTenant(t: string | undefined): void;
57
+ /** Generic escape hatch (forward-compat with endpoints added after this SDK). */
58
+ call(method: string, path: string, body?: unknown): Promise<unknown>;
59
+ }
60
+ export interface SynapseOneClient extends Pick<IamService, keyof IamService>, Pick<WorkflowService, keyof WorkflowService>, LdsLegacyMethods {
61
+ }
62
+ /**
63
+ * @deprecated Use {@link SynapseOneClient}. Kept for the SynapseDX -> SynapseOne
64
+ * rebrand window; this is the same class, not a subclass.
65
+ */
66
+ export { SynapseOneClient as SynapseDXClient };
package/dist/index.js ADDED
@@ -0,0 +1,143 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2026 SynapseOne Contributors
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * synapseone JavaScript SDK — works in Node 18+ and browsers (fetch-based).
6
+ *
7
+ * The SDK is split per service:
8
+ * client.iam auth/OIDC, orgs/accounts/users, roles, policies,
9
+ * API keys, service accounts, usage analytics
10
+ * client.workflow templates, workflow CRUD/lifecycle, executions, test runs,
11
+ * credentials, public inbound webhooks
12
+ * client.ai API assistant (natural language -> endpoint + body)
13
+ * client.lds LDS datasources/attributes/records/entities/licenses
14
+ * client.base SynapseBase collections/documents/queries/mapping
15
+ * client.faststore Synapse Faststore cache/KV, collections, locks
16
+ * client.queue SynapseQueue publish/consume/ack, dead letters
17
+ * client.inference LLM proxy, embeddings, decision + semantic routing
18
+ *
19
+ * The old flat methods still work but emit a DeprecationWarning pointing at the
20
+ * namespaced replacement (e.g. `client.listTemplates()` ->
21
+ * `client.workflow.listTemplates()`).
22
+ */
23
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
24
+ if (k2 === undefined) k2 = k;
25
+ var desc = Object.getOwnPropertyDescriptor(m, k);
26
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
27
+ desc = { enumerable: true, get: function() { return m[k]; } };
28
+ }
29
+ Object.defineProperty(o, k2, desc);
30
+ }) : (function(o, m, k, k2) {
31
+ if (k2 === undefined) k2 = k;
32
+ o[k2] = m[k];
33
+ }));
34
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
35
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
36
+ };
37
+ Object.defineProperty(exports, "__esModule", { value: true });
38
+ exports.SynapseDXClient = exports.SynapseOneClient = void 0;
39
+ const _http_1 = require("./_http");
40
+ const iam_1 = require("./iam");
41
+ const workflow_1 = require("./workflow");
42
+ const lds_1 = require("./lds");
43
+ const base_1 = require("./base");
44
+ const faststore_1 = require("./faststore");
45
+ const queue_1 = require("./queue");
46
+ const stream_1 = require("./stream");
47
+ const inference_1 = require("./inference");
48
+ const ai_1 = require("./ai");
49
+ __exportStar(require("./_http"), exports);
50
+ __exportStar(require("./iam"), exports);
51
+ __exportStar(require("./workflow"), exports);
52
+ __exportStar(require("./ai"), exports);
53
+ __exportStar(require("./lds"), exports);
54
+ __exportStar(require("./base"), exports);
55
+ __exportStar(require("./faststore"), exports);
56
+ __exportStar(require("./queue"), exports);
57
+ __exportStar(require("./stream"), exports);
58
+ __exportStar(require("./inference"), exports);
59
+ class SynapseOneClient {
60
+ http;
61
+ iam;
62
+ workflow;
63
+ ai;
64
+ lds;
65
+ base;
66
+ faststore;
67
+ queue;
68
+ stream;
69
+ inference;
70
+ constructor(opts) {
71
+ this.http = new _http_1.HttpClient(opts);
72
+ this.iam = new iam_1.IamService(this.http);
73
+ this.workflow = new workflow_1.WorkflowService(this.http);
74
+ this.ai = new ai_1.AiService(this.http);
75
+ this.lds = new lds_1.LdsService(this.http);
76
+ this.base = new base_1.BaseService(this.http);
77
+ this.faststore = new faststore_1.FaststoreService(this.http);
78
+ this.queue = new queue_1.QueueService(this.http);
79
+ this.stream = new stream_1.StreamService(this.http);
80
+ this.inference = new inference_1.InferenceService(this.http);
81
+ }
82
+ get baseUrl() { return this.http.baseUrl; }
83
+ setToken(t) { this.http.setToken(t); }
84
+ setApiKey(k) { this.http.setApiKey(k); }
85
+ setTenant(t) { this.http.setTenant(t); }
86
+ /** Generic escape hatch (forward-compat with endpoints added after this SDK). */
87
+ call(method, path, body) {
88
+ return this.http.call(method, path, body);
89
+ }
90
+ }
91
+ exports.SynapseOneClient = SynapseOneClient;
92
+ exports.SynapseDXClient = SynapseOneClient;
93
+ const IAM_METHODS = [
94
+ 'login', 'refresh', 'logout', 'logoutAll', 'verify', 'me',
95
+ 'oidcConfig', 'oidcStart', 'oidcCallback',
96
+ 'listOrgs', 'createOrg', 'listAccounts', 'listUsers', 'createUser',
97
+ 'createAccount', 'userPolicies',
98
+ 'createRole', 'listRoles', 'deleteRole', 'listPolicies', 'deletePolicy',
99
+ 'createPolicy', 'authorize', 'attachPolicy', 'detachPolicy', 'rolePolicies',
100
+ 'assignRole', 'unassignRole', 'userRoles', 'simulate', 'listAudit',
101
+ 'createApiKey', 'revokeApiKey', 'listApiKeys', 'verifyApiKey',
102
+ 'createServiceAccount', 'listServiceAccounts', 'serviceAccountToken',
103
+ 'usageSummary', 'usageEvents',
104
+ ];
105
+ const WORKFLOW_METHODS = [
106
+ 'listTemplates', 'getTemplate',
107
+ 'listWorkflows', 'getWorkflow', 'createWorkflowFromTemplate',
108
+ 'createWorkflow', 'updateWorkflow', 'deleteWorkflow',
109
+ 'activateWorkflow', 'deactivateWorkflow', 'executeWorkflow',
110
+ 'getExecution', 'listExecutions', 'testRun',
111
+ 'createCredential', 'listCredentials', 'getCredential', 'deleteCredential',
112
+ 'rotateCredential', 'triggerWebhook',
113
+ ];
114
+ const LDS_METHODS = [
115
+ ['ldsLicenses', 'licenses'],
116
+ ['ldsDatasources', 'datasources'],
117
+ ['ldsCreateDatasource', 'createDatasource'],
118
+ ['ldsDatasource', 'datasource'],
119
+ ['ldsUpdateDatasource', 'updateDatasource'],
120
+ ['ldsDeleteDatasource', 'deleteDatasource'],
121
+ ['ldsAttributes', 'attributes'],
122
+ ['ldsSetAttributes', 'setAttributes'],
123
+ ['ldsIngest', 'ingest'],
124
+ ['ldsEntities', 'entities'],
125
+ ['ldsEntity', 'entity'],
126
+ ['ldsStats', 'stats'],
127
+ ];
128
+ function defineLegacy(service, legacy, target) {
129
+ Object.defineProperty(SynapseOneClient.prototype, legacy, {
130
+ value: function (...args) {
131
+ (0, _http_1.warnDeprecated)(`client.${legacy}`, `client.${service}.${target}`);
132
+ return this[service][target](...args);
133
+ },
134
+ configurable: true,
135
+ writable: true,
136
+ });
137
+ }
138
+ for (const name of IAM_METHODS)
139
+ defineLegacy('iam', name, name);
140
+ for (const name of WORKFLOW_METHODS)
141
+ defineLegacy('workflow', name, name);
142
+ for (const [legacy, target] of LDS_METHODS)
143
+ defineLegacy('lds', legacy, target);
@@ -0,0 +1,110 @@
1
+ import { HttpClient } from './_http';
2
+ export interface InferenceHealthResponse {
3
+ status: string;
4
+ service: string;
5
+ version: string;
6
+ models: {
7
+ llm: string;
8
+ embedding: string;
9
+ decision: string;
10
+ };
11
+ components: {
12
+ llm: {
13
+ provider: string;
14
+ configured: boolean;
15
+ base_url?: string;
16
+ };
17
+ embedding: {
18
+ model: string;
19
+ dimension: number;
20
+ loaded: boolean;
21
+ device: string;
22
+ mock_mode: boolean;
23
+ error?: string | null;
24
+ };
25
+ decision: {
26
+ model: string;
27
+ architecture: string;
28
+ loaded: boolean;
29
+ device: string;
30
+ mock_mode: boolean;
31
+ error?: string | null;
32
+ };
33
+ };
34
+ time: string;
35
+ }
36
+ export interface ChatMessage {
37
+ role: 'system' | 'user' | 'assistant' | string;
38
+ content: string;
39
+ name?: string;
40
+ }
41
+ export interface ChatCompletionOptions {
42
+ model?: string;
43
+ temperature?: number;
44
+ max_tokens?: number;
45
+ stream?: boolean;
46
+ top_p?: number;
47
+ }
48
+ export interface ChatCompletionResponse {
49
+ id: string;
50
+ object: string;
51
+ created: number;
52
+ model: string;
53
+ choices: Array<{
54
+ index: number;
55
+ message: ChatMessage;
56
+ finish_reason: string;
57
+ }>;
58
+ usage?: {
59
+ prompt_tokens: number;
60
+ completion_tokens: number;
61
+ total_tokens: number;
62
+ };
63
+ }
64
+ export interface EmbeddingItem {
65
+ object: 'embedding';
66
+ index: number;
67
+ embedding: number[];
68
+ }
69
+ export interface EmbeddingResponse {
70
+ object: 'list';
71
+ data: EmbeddingItem[];
72
+ model: string;
73
+ usage: {
74
+ prompt_tokens: number;
75
+ total_tokens: number;
76
+ };
77
+ }
78
+ export interface DecisionQuestion {
79
+ type: 'choice' | 'noul' | 'score' | string;
80
+ instructions: string;
81
+ criteria?: Record<string, string>;
82
+ }
83
+ export interface DecisionResponse {
84
+ model: string;
85
+ results: Record<string, any>;
86
+ duration_ms: number;
87
+ }
88
+ export interface RouteResponse {
89
+ best_choice: string;
90
+ confidence: number;
91
+ probabilities: Record<string, number>;
92
+ model: string;
93
+ duration_ms: number;
94
+ }
95
+ export declare class InferenceService {
96
+ private readonly http;
97
+ constructor(http: HttpClient);
98
+ /** Check health and status of inference subsystems (LLM, embedding, decision). */
99
+ health(): Promise<InferenceHealthResponse>;
100
+ /** Run chat completions through the OpenRouter-backed LLM proxy. */
101
+ chat(messages: ChatMessage[], opts?: ChatCompletionOptions): Promise<ChatCompletionResponse>;
102
+ /** Generate text embeddings using the self-hosted lightweight model. */
103
+ embeddings(input: string | string[], opts?: {
104
+ model?: string;
105
+ }): Promise<EmbeddingResponse>;
106
+ /** Run structured question evaluation via Decision-2.0-Eos-0.8B (system_one). */
107
+ decision(state: string, questions: Record<string, DecisionQuestion>): Promise<DecisionResponse>;
108
+ /** Semantic route an input text between candidate choices for workflow branching. */
109
+ route(input: string, choices: Record<string, string>, instruction?: string): Promise<RouteResponse>;
110
+ }
@@ -0,0 +1,62 @@
1
+ "use strict";
2
+ /*
3
+ * Copyright 2026 SynapseOne Contributors
4
+ * Licensed under the Apache License, Version 2.0 (the "License");
5
+ * Synapse Inference Engine client: OpenRouter LLM proxy, self-hosted lightweight
6
+ * embeddings, and self-hosted Decision-2.0-Eos-0.8B structured routing.
7
+ */
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.InferenceService = void 0;
10
+ const P = '/v1/inference';
11
+ class InferenceService {
12
+ http;
13
+ constructor(http) {
14
+ this.http = http;
15
+ }
16
+ /** Check health and status of inference subsystems (LLM, embedding, decision). */
17
+ health() {
18
+ return this.http.req(`${P}/health`);
19
+ }
20
+ /** Run chat completions through the OpenRouter-backed LLM proxy. */
21
+ chat(messages, opts = {}) {
22
+ return this.http.req(`${P}/chat/completions`, {
23
+ method: 'POST',
24
+ body: JSON.stringify({
25
+ messages,
26
+ ...opts,
27
+ }),
28
+ });
29
+ }
30
+ /** Generate text embeddings using the self-hosted lightweight model. */
31
+ embeddings(input, opts = {}) {
32
+ return this.http.req(`${P}/embeddings`, {
33
+ method: 'POST',
34
+ body: JSON.stringify({
35
+ input,
36
+ ...opts,
37
+ }),
38
+ });
39
+ }
40
+ /** Run structured question evaluation via Decision-2.0-Eos-0.8B (system_one). */
41
+ decision(state, questions) {
42
+ return this.http.req(`${P}/decision`, {
43
+ method: 'POST',
44
+ body: JSON.stringify({
45
+ state,
46
+ questions,
47
+ }),
48
+ });
49
+ }
50
+ /** Semantic route an input text between candidate choices for workflow branching. */
51
+ route(input, choices, instruction) {
52
+ return this.http.req(`${P}/decision/route`, {
53
+ method: 'POST',
54
+ body: JSON.stringify({
55
+ input,
56
+ choices,
57
+ ...(instruction ? { instruction } : {}),
58
+ }),
59
+ });
60
+ }
61
+ }
62
+ exports.InferenceService = InferenceService;