@oasisomniverse/web6-api 1.0.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 ADDED
@@ -0,0 +1,177 @@
1
+ # @oasisomniverse/web6-api
2
+
3
+ Isomorphic (Node 18+ and browser) JavaScript/TypeScript-friendly client for the
4
+ **WEB6 OASIS AI Layer API** - full coverage of the OASIS2 WEB6 WebAPI: unified
5
+ AI completion/chat across every provider (OpenAI, Anthropic, Google Gemini,
6
+ xAI Grok, Qwen, DeepSeek, OpenServ, ...), image generation, the Holonic BRAID
7
+ fractal memory hierarchy and shared reasoning-graph library, multi-agent
8
+ orchestrator adapters (MCP/A2A/LangChain/AutoGen/CrewAI/Semantic Kernel), and
9
+ the Reasoning Network (FAHRN) for agent registration, scoring and dispatch.
10
+
11
+ Zero dependencies. Wraps the global `fetch`. Works the same in Node and the
12
+ browser.
13
+
14
+ ## Installation
15
+
16
+ ```bash
17
+ npm install @oasisomniverse/web6-api
18
+ ```
19
+
20
+ ## Quick start
21
+
22
+ ```js
23
+ const { Web6Client } = require('@oasisomniverse/web6-api');
24
+ // or: import { Web6Client } from '@oasisomniverse/web6-api';
25
+
26
+ const web6 = new Web6Client({ baseUrl: 'https://api.web6.oasisomniverse.one' });
27
+
28
+ const { isError, message, result } = await web6.completion.complete({
29
+ avatarId,
30
+ messages: [{ role: 'user', content: 'Hello!' }]
31
+ });
32
+ if (isError) throw new Error(message);
33
+ console.log(result);
34
+ ```
35
+
36
+ ## Calling any endpoint
37
+
38
+ Every controller on the OASIS2 WEB6 WebAPI is reachable as a lowerCamel
39
+ property on the client (`web6.completion`, `web6.images`,
40
+ `web6.holonicMemory`, `web6.holonicBraid`, `web6.orchestrator`,
41
+ `web6.reasoningNetwork`). Every generated method takes a single args object:
42
+
43
+ - Any key matching a `{token}` in the route template is consumed and
44
+ substituted into the URL (case-insensitive match).
45
+ - Any remaining keys become the query string (GET/DELETE) or JSON body
46
+ (POST/PUT) - **matching the real `[FromQuery]`/`[FromBody]` binding of the
47
+ underlying C# action**, not just the HTTP verb. `endpoints.json` records
48
+ exactly which arg names are query-bound per operation (see
49
+ [`docs/`](./docs/README.md) for the per-method breakdown), so a `POST`
50
+ action that binds some params from the query string (like
51
+ `HolonicMemoryController.GetOrCreateHolon`) still sends those on the URL.
52
+
53
+ ```js
54
+ // GET v1/holonic-braid/graph/{taskType} -> taskType is consumed as a route token
55
+ const graph = await web6.holonicBraid.getGraph({ taskType: 'research' });
56
+
57
+ // PUT v1/holonic-memory/holons/{holonId}/membrane-rule -> holonId consumed, rest becomes the body
58
+ await web6.holonicMemory.setMembraneRule({ holonId, allow: ['propagate-up'] });
59
+
60
+ // POST v1/holonic-memory/holons -> level/name/parentHolonId are all [FromQuery]
61
+ // even though this is a POST, so they're sent on the URL, not as a JSON body
62
+ const holon = await web6.holonicMemory.getOrCreateHolon({ level: 'Local', name: 'London', parentHolonId: earthId });
63
+ ```
64
+
65
+ Every response has the shape:
66
+
67
+ ```ts
68
+ interface OASISResponse<T = any> {
69
+ isError: boolean;
70
+ message: string | null;
71
+ result: T;
72
+ raw: any;
73
+ statusCode: number;
74
+ }
75
+ ```
76
+
77
+ ## Auth
78
+
79
+ WEB6 is an internal AI layer that sits behind the same OASIS avatar identity
80
+ as WEB4/WEB5 - it has no avatar/login endpoints of its own. Reuse a JWT
81
+ you've already obtained elsewhere (e.g. from `web4-oasis-api`'s
82
+ `client.auth.login()`):
83
+
84
+ ```js
85
+ web6.setToken(jwtToken);
86
+ ```
87
+
88
+ ## Module examples
89
+
90
+ ### Completion (`web6.completion`)
91
+
92
+ ```js
93
+ const reply = await web6.completion.complete({
94
+ avatarId,
95
+ provider: 'OpenAI',
96
+ messages: [{ role: 'user', content: 'Summarise this holon graph.' }]
97
+ });
98
+
99
+ const models = await web6.completion.openServModels();
100
+ ```
101
+
102
+ ### Images (`web6.images`)
103
+
104
+ ```js
105
+ const image = await web6.images.generate({ prompt: 'a holonic crystal city at dawn', provider: 'StabilityAI' });
106
+ ```
107
+
108
+ ### Holonic Memory (`web6.holonicMemory`)
109
+
110
+ ```js
111
+ const earth = await web6.holonicMemory.getEarthHolon();
112
+ const holon = await web6.holonicMemory.getOrCreateHolon({ level: 'Local', name: 'London', parentHolonId: earth.result.id });
113
+ await web6.holonicMemory.recordMemory({ holonId: holon.result.id, content: 'New observation...' });
114
+ await web6.holonicMemory.propagate({ childHolonId: holon.result.id });
115
+ ```
116
+
117
+ ### Holonic BRAID (`web6.holonicBraid`)
118
+
119
+ ```js
120
+ const graph = await web6.holonicBraid.getGraph({ taskType: 'research' });
121
+ await web6.holonicBraid.saveGraph({ taskType: 'research', nodes: graph.result.nodes });
122
+ ```
123
+
124
+ ### Orchestrator (`web6.orchestrator`)
125
+
126
+ ```js
127
+ await web6.orchestrator.registerAdapter({ protocol: 'MCP', endpoint: 'https://my-agent.example.com' });
128
+ const adapters = await web6.orchestrator.getAdapters();
129
+ await web6.orchestrator.invoke({ adapterId, payload: { task: 'lookup-weather' } });
130
+ ```
131
+
132
+ ### Reasoning Network (`web6.reasoningNetwork`)
133
+
134
+ ```js
135
+ await web6.reasoningNetwork.registerAgent({ name: 'researcher-1', capabilities: ['search', 'summarise'] });
136
+ await web6.reasoningNetwork.seedOpenServAgents();
137
+ const result = await web6.reasoningNetwork.dispatch({ taskType: 'research', payload: { query: 'OASIS HyperDrive' } });
138
+ ```
139
+
140
+ ## Module reference
141
+
142
+ 6 modules, 18 operations in total. Full per-method tables live in
143
+ [`docs/`](./docs/README.md).
144
+
145
+ | Client property | Route prefix | Operations |
146
+ | --- | --- | --- |
147
+ | `web6.completion` | `v1` | 2 |
148
+ | `web6.holonicBraid` | `v1/holonic-braid` | 2 |
149
+ | `web6.holonicMemory` | `v1/holonic-memory` | 5 |
150
+ | `web6.images` | `v1/images` | 1 |
151
+ | `web6.orchestrator` | `v1/orchestrators` | 3 |
152
+ | `web6.reasoningNetwork` | `v1/reasoning-network` | 4 |
153
+
154
+ See [`docs/README.md`](./docs/README.md) for the full generated reference,
155
+ or [`docs/modules/`](./docs/modules) for per-module method tables with
156
+ parameter and route details.
157
+
158
+ ## Regenerating
159
+
160
+ The generated modules, type declarations and docs are produced from
161
+ `endpoints.json` (extracted from the WEB6 WebAPI controller source):
162
+
163
+ ```bash
164
+ npm run generate # src/modules/*.js + src/modules/index.js
165
+ npm run types # src/modules/*.d.ts + index.d.ts + src/core/types.d.ts
166
+ npm run docs # docs/README.md + docs/modules/*.md
167
+ ```
168
+
169
+ ## Testing
170
+
171
+ ```bash
172
+ npm test
173
+ ```
174
+
175
+ ## License
176
+
177
+ MIT
package/docs/README.md ADDED
@@ -0,0 +1,24 @@
1
+ # WEB6 AI Layer API — JavaScript SDK Reference
2
+
3
+ Generated from `endpoints.json` (extracted from the WebAPI controllers) by
4
+ `scripts/generate-full-docs.js`. Regenerate the full pipeline after the API
5
+ changes:
6
+
7
+ ```
8
+ node scripts/extract-endpoints.js
9
+ node scripts/generate-modules.js
10
+ node scripts/generate-full-docs.js
11
+ ```
12
+
13
+ - [Module Reference](#module-reference) (6 modules, 17 operations)
14
+
15
+ ## Module Reference
16
+
17
+ | Client property | Route prefix | Operations |
18
+ | --- | --- | --- |
19
+ | [`web6.completion`](modules/Completion.md) | `v1` | 2 |
20
+ | [`web6.holonicBraid`](modules/HolonicBraid.md) | `v1/holonic-braid` | 2 |
21
+ | [`web6.holonicMemory`](modules/HolonicMemory.md) | `v1/holonic-memory` | 5 |
22
+ | [`web6.images`](modules/Images.md) | `v1/images` | 1 |
23
+ | [`web6.orchestrator`](modules/Orchestrator.md) | `v1/orchestrators` | 3 |
24
+ | [`web6.reasoningNetwork`](modules/ReasoningNetwork.md) | `v1/reasoning-network` | 4 |
@@ -0,0 +1,124 @@
1
+ # Completion — `web6.completion`
2
+
3
+ Source controller: [`CompletionController.cs`](https://github.com/NextGenSoftwareUK/OASIS2/blob/main/WEB6/NextGenSoftware.OASIS.Web6.WebAPI/Controllers/CompletionController.cs)
4
+ Route prefix: `v1`
5
+ 2 operation(s).
6
+
7
+ Every method takes a single args object: any key matching a `{token}` in the route is substituted into the URL; everything else becomes the query string (GET/DELETE) or JSON body (POST/PUT). Every call resolves to the standard OASIS envelope:
8
+
9
+ ```ts
10
+ {
11
+ isError: boolean;
12
+ isWarning: boolean;
13
+ message: string;
14
+ errorCode?: string;
15
+ result: T; // see each endpoint's Response section below
16
+ }
17
+ ```
18
+
19
+ ## Operations
20
+
21
+ ### `complete`
22
+
23
+ Routes a completion request to whichever AI provider/model best fits, normalising the response. POST https://api.web6.oasisomniverse.one/v1/complete
24
+
25
+ **POST** `v1/complete`
26
+
27
+ **Request**
28
+
29
+ Body type: `CompletionRequest`
30
+
31
+ | Field | Type |
32
+ | --- | --- |
33
+ | `Provider` | `string` |
34
+ | `Model` | `string` |
35
+ | `Messages` | `List<ChatMessage>` |
36
+ | `Routing` | `RoutingOptions` |
37
+ | `AvatarId` | `Guid` |
38
+ | `Temperature` | `double?` |
39
+ | `MaxTokens` | `int?` |
40
+
41
+ **Response**
42
+
43
+ Standard `OASISResult` envelope (see top of this page) with:
44
+
45
+ `result` type: `CompletionResponse`
46
+
47
+ | Field | Type |
48
+ | --- | --- |
49
+ | `Id` | `string` |
50
+ | `Provider` | `string` |
51
+ | `Model` | `string` |
52
+ | `Content` | `string` |
53
+ | `PromptTokens` | `int` |
54
+ | `CompletionTokens` | `int` |
55
+ | `LatencyMs` | `long` |
56
+ | `FailedOver` | `bool` |
57
+
58
+ **Example**
59
+
60
+ ```js
61
+ const { isError, message, result } = await web6.completion.complete({
62
+ provider: "example string",
63
+ model: "example string",
64
+ messages: [{ "Id": "example string", "SessionId": "example string", "SenderId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "Content": "example string", "MessageType": { }, "Timestamp": "2026-01-01T00:00:00Z", "IsDelivered": true, "IsRead": true }],
65
+ routing: { "Priority": "example string", "Fallback": true },
66
+ avatarId: "3fa85f64-5717-4562-b3fc-2c963f66afa6",
67
+ temperature: 1.0,
68
+ maxTokens: 1
69
+ });
70
+ if (isError) throw new Error(message);
71
+ console.log(result);
72
+ ```
73
+
74
+ Example response:
75
+
76
+ ```json
77
+ {
78
+ "isError": false,
79
+ "message": "",
80
+ "result": { "Id": "example string", "Provider": "example string", "Model": "example string", "Content": "example string", "PromptTokens": 1, "CompletionTokens": 1, "LatencyMs": 1, "FailedOver": true }
81
+ }
82
+ ```
83
+
84
+ ---
85
+
86
+ ### `openServModels`
87
+
88
+ Lists the models reachable through the OpenServ provider (provider: "openserv"), i.e. the full SERV catalog spanning OpenAI, Anthropic, Google, xAI, Qwen and DeepSeek behind one SERV_API_KEY. GET https://api.web6.oasisomniverse.one/v1/openserv/models
89
+
90
+ **GET** `v1/openserv/models`
91
+
92
+ **Request**
93
+
94
+ No request body.
95
+
96
+ **Response**
97
+
98
+ Standard `OASISResult` envelope (see top of this page) with:
99
+
100
+ `result` type: `OpenServModel` (array)
101
+
102
+ | Field | Type |
103
+ | --- | --- |
104
+ | `Id` | `string` |
105
+ | `Label` | `string` |
106
+
107
+ **Example**
108
+
109
+ ```js
110
+ const { isError, message, result } = await web6.completion.openServModels({});
111
+ if (isError) throw new Error(message);
112
+ console.log(result);
113
+ ```
114
+
115
+ Example response:
116
+
117
+ ```json
118
+ {
119
+ "isError": false,
120
+ "message": "",
121
+ "result": [{ "Id": "example string", "Label": "example string" }]
122
+ }
123
+ ```
124
+
@@ -0,0 +1,137 @@
1
+ # HolonicBraid — `web6.holonicBraid`
2
+
3
+ Source controller: [`HolonicBraidController.cs`](https://github.com/NextGenSoftwareUK/OASIS2/blob/main/WEB6/NextGenSoftware.OASIS.Web6.WebAPI/Controllers/HolonicBraidController.cs)
4
+ Route prefix: `v1/holonic-braid`
5
+ 2 operation(s).
6
+
7
+ Every method takes a single args object: any key matching a `{token}` in the route is substituted into the URL; everything else becomes the query string (GET/DELETE) or JSON body (POST/PUT). Every call resolves to the standard OASIS envelope:
8
+
9
+ ```ts
10
+ {
11
+ isError: boolean;
12
+ isWarning: boolean;
13
+ message: string;
14
+ errorCode?: string;
15
+ result: T; // see each endpoint's Response section below
16
+ }
17
+ ```
18
+
19
+ ## Operations
20
+
21
+ ### `getGraph`
22
+
23
+ Looks up the shared reasoning graph already generated for a task type, if any.
24
+
25
+ **GET** `v1/holonic-braid/graph/{taskType}`
26
+
27
+ Route parameters:
28
+
29
+ | Field | Type |
30
+ | --- | --- |
31
+ | `taskType` | `string` |
32
+
33
+ **Request**
34
+
35
+ No request body.
36
+
37
+ **Response**
38
+
39
+ Standard `OASISResult` envelope (see top of this page) with:
40
+
41
+ `result` type: `HolonicBraidGraphDto`
42
+
43
+ | Field | Type |
44
+ | --- | --- |
45
+ | `Id` | `Guid` |
46
+ | `TaskType` | `string` |
47
+ | `MermaidDiagram` | `string` |
48
+ | `GeneratedByModel` | `string` |
49
+ | `TimesReused` | `int` |
50
+ | `CreatedUtc` | `DateTime` |
51
+ | `ParentHolonId` | `Guid` |
52
+ | `AvgSolverAccuracy` | `double` |
53
+ | `Version` | `int` |
54
+
55
+ **Example**
56
+
57
+ ```js
58
+ const { isError, message, result } = await web6.holonicBraid.getGraph({
59
+ taskType: '<taskType>'
60
+ });
61
+ if (isError) throw new Error(message);
62
+ console.log(result);
63
+ ```
64
+
65
+ Example response:
66
+
67
+ ```json
68
+ {
69
+ "isError": false,
70
+ "message": "",
71
+ "result": { "Id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "TaskType": "example string", "MermaidDiagram": "example string", "GeneratedByModel": "example string", "TimesReused": 1, "CreatedUtc": "2026-01-01T00:00:00Z", "ParentHolonId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "AvgSolverAccuracy": 1.0, "Version": 1 }
72
+ }
73
+ ```
74
+
75
+ ---
76
+
77
+ ### `saveGraph`
78
+
79
+ Seeds the shared library with a reasoning graph for a task type (the "generator" step of the two-stage BRAID protocol).
80
+
81
+ **POST** `v1/holonic-braid/graph/{taskType}`
82
+
83
+ Route parameters:
84
+
85
+ | Field | Type |
86
+ | --- | --- |
87
+ | `taskType` | `string` |
88
+
89
+ **Request**
90
+
91
+ Body type: `SaveGraphRequest`
92
+
93
+ | Field | Type |
94
+ | --- | --- |
95
+ | `MermaidDiagram` | `string` |
96
+ | `GeneratedByModel` | `string` |
97
+
98
+ **Response**
99
+
100
+ Standard `OASISResult` envelope (see top of this page) with:
101
+
102
+ `result` type: `HolonicBraidGraphDto`
103
+
104
+ | Field | Type |
105
+ | --- | --- |
106
+ | `Id` | `Guid` |
107
+ | `TaskType` | `string` |
108
+ | `MermaidDiagram` | `string` |
109
+ | `GeneratedByModel` | `string` |
110
+ | `TimesReused` | `int` |
111
+ | `CreatedUtc` | `DateTime` |
112
+ | `ParentHolonId` | `Guid` |
113
+ | `AvgSolverAccuracy` | `double` |
114
+ | `Version` | `int` |
115
+
116
+ **Example**
117
+
118
+ ```js
119
+ const { isError, message, result } = await web6.holonicBraid.saveGraph({
120
+ taskType: '<taskType>',
121
+ mermaidDiagram: "example string",
122
+ generatedByModel: "example string"
123
+ });
124
+ if (isError) throw new Error(message);
125
+ console.log(result);
126
+ ```
127
+
128
+ Example response:
129
+
130
+ ```json
131
+ {
132
+ "isError": false,
133
+ "message": "",
134
+ "result": { "Id": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "TaskType": "example string", "MermaidDiagram": "example string", "GeneratedByModel": "example string", "TimesReused": 1, "CreatedUtc": "2026-01-01T00:00:00Z", "ParentHolonId": "3fa85f64-5717-4562-b3fc-2c963f66afa6", "AvgSolverAccuracy": 1.0, "Version": 1 }
135
+ }
136
+ ```
137
+