@dimo-network/data-sdk 1.4.0 → 1.5.2
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/.github/workflows/npm-publish.yml +6 -3
- package/README.md +82 -0
- package/dist/api/Method.js +7 -2
- package/dist/api/Method.test.js +10 -5
- package/dist/api/resources/Agents/index.d.ts +5 -0
- package/dist/api/resources/Agents/index.js +63 -0
- package/dist/api/resources/DimoRestResources.d.ts +3 -1
- package/dist/api/resources/DimoRestResources.js +3 -1
- package/dist/api/resources/Fetch/index.d.ts +5 -0
- package/dist/api/resources/Fetch/index.js +64 -0
- package/dist/cjs/index.js +144 -2
- package/dist/cjs/index.js.map +1 -1
- package/dist/dimo.d.ts +3 -1
- package/dist/dimo.js +5 -1
- package/dist/dimo.test.js +4 -0
- package/dist/environments/index.d.ts +4 -0
- package/dist/environments/index.js +4 -0
- package/dist/esm/index.js +143 -3
- package/dist/esm/index.js.map +1 -1
- package/dist/types/api/resources/Agents/index.d.ts +5 -0
- package/dist/types/api/resources/DimoRestResources.d.ts +3 -1
- package/dist/types/api/resources/Fetch/index.d.ts +5 -0
- package/dist/types/dimo.d.ts +3 -1
- package/dist/types/environments/index.d.ts +4 -0
- package/package.json +3 -2
|
@@ -29,12 +29,17 @@ jobs:
|
|
|
29
29
|
publish-npm:
|
|
30
30
|
needs: build
|
|
31
31
|
runs-on: ubuntu-latest
|
|
32
|
+
permissions:
|
|
33
|
+
id-token: write # Required for OIDC
|
|
34
|
+
contents: read
|
|
32
35
|
steps:
|
|
33
36
|
- uses: actions/checkout@v4
|
|
34
|
-
- uses: actions/setup-node@
|
|
37
|
+
- uses: actions/setup-node@v4
|
|
35
38
|
with:
|
|
36
39
|
node-version: 20
|
|
37
40
|
registry-url: https://registry.npmjs.org/
|
|
41
|
+
- name: Install latest npm
|
|
42
|
+
run: npm install -g npm@latest
|
|
38
43
|
- name: Clear npm cache
|
|
39
44
|
run: npm cache clean --force
|
|
40
45
|
- name: Install dependencies
|
|
@@ -46,5 +51,3 @@ jobs:
|
|
|
46
51
|
- name: Check dist directory
|
|
47
52
|
run: ls dist/
|
|
48
53
|
- run: npm publish --access public
|
|
49
|
-
env:
|
|
50
|
-
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
|
package/README.md
CHANGED
|
@@ -293,5 +293,87 @@ const totalNetworkVehicles = await dimo.identity.query({
|
|
|
293
293
|
|
|
294
294
|
This GraphQL API query is equivalent to calling `dimo.identity.countDimoVehicles()`.
|
|
295
295
|
|
|
296
|
+
### Agents API
|
|
297
|
+
|
|
298
|
+
The DIMO Agents API enables developers to create intelligent AI agents that can interact with vehicle data through natural language. These agents can query vehicle information, real-time telemetry, perform web searches to answer questions about vehicles and nearby services, and more.
|
|
299
|
+
|
|
300
|
+
#### Create an Agent
|
|
301
|
+
|
|
302
|
+
Create a new conversational AI agent with the specified configuration:
|
|
303
|
+
|
|
304
|
+
```ts
|
|
305
|
+
const agent = await dimo.agents.createAgent({
|
|
306
|
+
...developerJwt,
|
|
307
|
+
type: "driver_agent_v1", // Optional: defaults to "driver_agent_v1"
|
|
308
|
+
personality: "uncle_mechanic", // Optional: defaults to "uncle_mechanic"
|
|
309
|
+
secrets: {
|
|
310
|
+
DIMO_API_KEY: "<YOUR_API_KEY>"
|
|
311
|
+
},
|
|
312
|
+
variables: {
|
|
313
|
+
USER_WALLET: "0x1234567890abcdef1234567890abcdef12345678",
|
|
314
|
+
VEHICLE_IDS: "[872, 1234]"
|
|
315
|
+
}
|
|
316
|
+
});
|
|
317
|
+
```
|
|
318
|
+
|
|
319
|
+
Available personalities: `uncle_mechanic`, `master_technician`, `concierge`, `driving_enthusiast`, `fleet_manager_pro`
|
|
320
|
+
|
|
321
|
+
#### Send a Message
|
|
322
|
+
|
|
323
|
+
Send a message to an agent and receive a complete response synchronously:
|
|
324
|
+
|
|
325
|
+
```ts
|
|
326
|
+
const response = await dimo.agents.sendMessage({
|
|
327
|
+
...developerJwt,
|
|
328
|
+
agentId: "agent-abc123def456",
|
|
329
|
+
message: "What's the make and model of my vehicle?"
|
|
330
|
+
});
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
#### Stream a Message
|
|
334
|
+
|
|
335
|
+
Send a message and receive real-time token-by-token streaming response:
|
|
336
|
+
|
|
337
|
+
```ts
|
|
338
|
+
const stream = await dimo.agents.streamMessage({
|
|
339
|
+
...developerJwt,
|
|
340
|
+
agentId: "agent-abc123def456",
|
|
341
|
+
message: "What's my current speed?"
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
stream.on('token', (chunk) => {
|
|
345
|
+
console.log(chunk.content);
|
|
346
|
+
});
|
|
347
|
+
|
|
348
|
+
stream.on('done', (metadata) => {
|
|
349
|
+
console.log('Vehicles queried:', metadata.vehiclesQueried);
|
|
350
|
+
});
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
#### Get Conversation History
|
|
354
|
+
|
|
355
|
+
Retrieve the complete conversation history for an agent:
|
|
356
|
+
|
|
357
|
+
```ts
|
|
358
|
+
const history = await dimo.agents.getHistory({
|
|
359
|
+
...developerJwt,
|
|
360
|
+
agentId: "agent-abc123def456",
|
|
361
|
+
limit: 50 // Optional
|
|
362
|
+
});
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
#### Delete an Agent
|
|
366
|
+
|
|
367
|
+
Permanently delete an agent and all associated resources:
|
|
368
|
+
|
|
369
|
+
```ts
|
|
370
|
+
await dimo.agents.deleteAgent({
|
|
371
|
+
...developerJwt,
|
|
372
|
+
agentId: "agent-abc123def456"
|
|
373
|
+
});
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
For more details, visit the [Agents API Documentation](https://www.dimo.org/docs/api-references/agents-api).
|
|
377
|
+
|
|
296
378
|
## How to Contribute to the SDK
|
|
297
379
|
Read more about contributing [here](https://github.com/DIMO-Network/data-sdk/blob/master/CONTRIBUTING.md).
|
package/dist/api/Method.js
CHANGED
|
@@ -87,14 +87,19 @@ export const Method = async (resource, baseUrl, params = {}, env) => {
|
|
|
87
87
|
let body = {};
|
|
88
88
|
if (resource.body) {
|
|
89
89
|
for (const key in resource.body) {
|
|
90
|
-
if (
|
|
90
|
+
if (resource.body[key] === true) {
|
|
91
|
+
// Required field
|
|
91
92
|
if (!params[key]) {
|
|
92
93
|
console.error(`Missing required body parameter: ${key}`);
|
|
93
94
|
throw new DimoError({
|
|
94
95
|
message: `Missing required body parameter: ${key}`
|
|
95
96
|
});
|
|
96
97
|
}
|
|
97
|
-
|
|
98
|
+
body[key] = params[key];
|
|
99
|
+
}
|
|
100
|
+
else if (resource.body[key] === false) {
|
|
101
|
+
// Optional field - include only if provided
|
|
102
|
+
if (params[key] !== undefined) {
|
|
98
103
|
body[key] = params[key];
|
|
99
104
|
}
|
|
100
105
|
}
|
package/dist/api/Method.test.js
CHANGED
|
@@ -2,6 +2,8 @@ import axios from 'axios';
|
|
|
2
2
|
import { Method } from './Method'; // Import the Method function to be tested
|
|
3
3
|
import { DimoError } from '../errors';
|
|
4
4
|
import { DimoEnvironment } from '../environments';
|
|
5
|
+
jest.mock('axios');
|
|
6
|
+
const mockedAxios = axios;
|
|
5
7
|
const PROD = 'Production';
|
|
6
8
|
const DEV = 'Dev';
|
|
7
9
|
const RESOURCE = {
|
|
@@ -11,8 +13,11 @@ const RESOURCE = {
|
|
|
11
13
|
};
|
|
12
14
|
const PARAM = { param1: 'value1' };
|
|
13
15
|
describe('Method Function', () => {
|
|
16
|
+
beforeEach(() => {
|
|
17
|
+
jest.clearAllMocks();
|
|
18
|
+
});
|
|
14
19
|
test('Valid API Call - Device Definitions API Server is up and returning data', async () => {
|
|
15
|
-
|
|
20
|
+
mockedAxios.mockResolvedValue({ data: 'device definitions api running!' });
|
|
16
21
|
const devResponse = await Method(RESOURCE, DimoEnvironment.Dev.DeviceDefinitions, PARAM, DEV);
|
|
17
22
|
const prodResponse = await Method(RESOURCE, DimoEnvironment.Production.DeviceDefinitions, PARAM, PROD);
|
|
18
23
|
// Assertion - Check if the response data is returned correctly
|
|
@@ -20,7 +25,7 @@ describe('Method Function', () => {
|
|
|
20
25
|
expect(prodResponse).toEqual('device definitions api running!');
|
|
21
26
|
});
|
|
22
27
|
test('Valid API Call - Devices API Server is up and returning data', async () => {
|
|
23
|
-
|
|
28
|
+
mockedAxios.mockResolvedValue({ data: { data: 'Server is up and running' } });
|
|
24
29
|
const devResponse = await Method(RESOURCE, DimoEnvironment.Dev.Devices, PARAM, DEV);
|
|
25
30
|
const prodResponse = await Method(RESOURCE, DimoEnvironment.Production.Devices, PARAM, PROD);
|
|
26
31
|
// Assertion - Check if the response data is returned correctly
|
|
@@ -28,7 +33,7 @@ describe('Method Function', () => {
|
|
|
28
33
|
expect(prodResponse).toEqual({ data: 'Server is up and running' });
|
|
29
34
|
});
|
|
30
35
|
test('Valid API Call - Token Exchange API Server is up and returning data', async () => {
|
|
31
|
-
|
|
36
|
+
mockedAxios.mockResolvedValue({ data: { data: 'Server is up and running' } });
|
|
32
37
|
const devResponse = await Method(RESOURCE, DimoEnvironment.Dev.TokenExchange, PARAM, DEV);
|
|
33
38
|
const prodResponse = await Method(RESOURCE, DimoEnvironment.Production.TokenExchange, PARAM, PROD);
|
|
34
39
|
// Assertion - Check if the response data is returned correctly
|
|
@@ -36,7 +41,7 @@ describe('Method Function', () => {
|
|
|
36
41
|
expect(prodResponse).toEqual({ data: 'Server is up and running' });
|
|
37
42
|
});
|
|
38
43
|
test('Valid API Call - Valuations API Server is up and returning data', async () => {
|
|
39
|
-
|
|
44
|
+
mockedAxios.mockResolvedValue({ data: { code: 200, message: 'Server is up.' } });
|
|
40
45
|
const devResponse = await Method(RESOURCE, DimoEnvironment.Dev.Valuations, PARAM, DEV);
|
|
41
46
|
const prodResponse = await Method(RESOURCE, DimoEnvironment.Production.Valuations, PARAM, PROD);
|
|
42
47
|
// Assertion - Check if the response data is returned correctly
|
|
@@ -44,7 +49,7 @@ describe('Method Function', () => {
|
|
|
44
49
|
expect(prodResponse).toEqual({ code: 200, message: 'Server is up.' });
|
|
45
50
|
});
|
|
46
51
|
test('Valid API Call - Vehicle Signal Decoding API Server is up and returning data', async () => {
|
|
47
|
-
|
|
52
|
+
mockedAxios.mockResolvedValue({ data: 'healthy' });
|
|
48
53
|
const devResponse = await Method(RESOURCE, DimoEnvironment.Dev.VehicleSignalDecoding, PARAM, DEV);
|
|
49
54
|
const prodResponse = await Method(RESOURCE, DimoEnvironment.Production.VehicleSignalDecoding, PARAM, PROD);
|
|
50
55
|
// Assertion - Check if the response data is returned correctly
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import { Resource } from '../../Resource';
|
|
2
|
+
export class Agents extends Resource {
|
|
3
|
+
constructor(api, env) {
|
|
4
|
+
super(api, 'Agents', env);
|
|
5
|
+
this.setResource({
|
|
6
|
+
healthCheck: {
|
|
7
|
+
method: 'GET',
|
|
8
|
+
path: '/'
|
|
9
|
+
},
|
|
10
|
+
createAgent: {
|
|
11
|
+
method: 'POST',
|
|
12
|
+
path: '/agents',
|
|
13
|
+
body: {
|
|
14
|
+
'type': false,
|
|
15
|
+
'personality': false,
|
|
16
|
+
'secrets': true,
|
|
17
|
+
'variables': true,
|
|
18
|
+
},
|
|
19
|
+
auth: 'developer_jwt'
|
|
20
|
+
},
|
|
21
|
+
deleteAgent: {
|
|
22
|
+
method: 'DELETE',
|
|
23
|
+
path: '/agents/:agentId',
|
|
24
|
+
auth: 'developer_jwt'
|
|
25
|
+
},
|
|
26
|
+
sendMessage: {
|
|
27
|
+
method: 'POST',
|
|
28
|
+
path: '/agents/:agentId/message',
|
|
29
|
+
body: {
|
|
30
|
+
'message': true,
|
|
31
|
+
'vehicleIds': false,
|
|
32
|
+
'user': false
|
|
33
|
+
},
|
|
34
|
+
auth: 'developer_jwt'
|
|
35
|
+
},
|
|
36
|
+
streamMessage: {
|
|
37
|
+
method: 'POST',
|
|
38
|
+
path: '/agents/:agentId/stream',
|
|
39
|
+
body: {
|
|
40
|
+
'message': true,
|
|
41
|
+
'vehicleIds': false,
|
|
42
|
+
'user': false
|
|
43
|
+
},
|
|
44
|
+
auth: 'developer_jwt'
|
|
45
|
+
},
|
|
46
|
+
getHistory: {
|
|
47
|
+
method: 'GET',
|
|
48
|
+
path: '/agents/:agentId/history',
|
|
49
|
+
queryParams: {
|
|
50
|
+
'limit': false
|
|
51
|
+
},
|
|
52
|
+
auth: 'developer_jwt'
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
const originalCreateAgent = this.createAgent;
|
|
56
|
+
this.createAgent = (params = {}) => {
|
|
57
|
+
return originalCreateAgent({
|
|
58
|
+
type: 'driver_agent_v1',
|
|
59
|
+
...params
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/** @format */
|
|
2
|
+
import { Agents } from './Agents';
|
|
2
3
|
import { Attestation } from './Attestation';
|
|
3
4
|
import { Auth } from './Auth';
|
|
4
5
|
import { DeviceDefinitions } from './DeviceDefinitions';
|
|
5
6
|
import { Devices } from './Devices';
|
|
7
|
+
import { Fetch } from './Fetch';
|
|
6
8
|
import { TokenExchange } from './TokenExchange';
|
|
7
9
|
import { Trips } from './Trips';
|
|
8
10
|
import { Valuations } from './Valuations';
|
|
9
11
|
import { VehicleTriggers } from './VehicleTriggers';
|
|
10
|
-
export { Attestation, Auth, DeviceDefinitions, Devices, TokenExchange, Trips, Valuations, VehicleTriggers, };
|
|
12
|
+
export { Agents, Attestation, Auth, DeviceDefinitions, Devices, Fetch, TokenExchange, Trips, Valuations, VehicleTriggers, };
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
/** @format */
|
|
2
|
+
import { Agents } from './Agents';
|
|
2
3
|
import { Attestation } from './Attestation';
|
|
3
4
|
import { Auth } from './Auth';
|
|
4
5
|
import { DeviceDefinitions } from './DeviceDefinitions';
|
|
5
6
|
import { Devices } from './Devices';
|
|
7
|
+
import { Fetch } from './Fetch';
|
|
6
8
|
import { TokenExchange } from './TokenExchange';
|
|
7
9
|
import { Trips } from './Trips';
|
|
8
10
|
import { Valuations } from './Valuations';
|
|
9
11
|
import { VehicleTriggers } from './VehicleTriggers';
|
|
10
|
-
export { Attestation, Auth, DeviceDefinitions, Devices, TokenExchange, Trips, Valuations, VehicleTriggers, };
|
|
12
|
+
export { Agents, Attestation, Auth, DeviceDefinitions, Devices, Fetch, TokenExchange, Trips, Valuations, VehicleTriggers, };
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { Resource } from '../../Resource';
|
|
2
|
+
export class Fetch extends Resource {
|
|
3
|
+
constructor(api, env) {
|
|
4
|
+
super(api, 'Fetch', env);
|
|
5
|
+
this.setResource({
|
|
6
|
+
getIndexKeys: {
|
|
7
|
+
method: 'GET',
|
|
8
|
+
path: '/v1/vehicle/index-keys/:tokenId',
|
|
9
|
+
queryParams: {
|
|
10
|
+
after: false,
|
|
11
|
+
before: false,
|
|
12
|
+
id: false,
|
|
13
|
+
limit: false,
|
|
14
|
+
producer: false,
|
|
15
|
+
source: false,
|
|
16
|
+
type: false
|
|
17
|
+
},
|
|
18
|
+
auth: 'vehicle_jwt'
|
|
19
|
+
},
|
|
20
|
+
getLatestIndexKey: {
|
|
21
|
+
method: 'GET',
|
|
22
|
+
path: '/v1/vehicle/latest-index-key/:tokenId',
|
|
23
|
+
queryParams: {
|
|
24
|
+
after: false,
|
|
25
|
+
before: false,
|
|
26
|
+
id: false,
|
|
27
|
+
limit: false,
|
|
28
|
+
producer: false,
|
|
29
|
+
source: false,
|
|
30
|
+
type: false
|
|
31
|
+
},
|
|
32
|
+
auth: 'vehicle_jwt'
|
|
33
|
+
},
|
|
34
|
+
getLatestObject: {
|
|
35
|
+
method: 'GET',
|
|
36
|
+
path: '/v1/vehicle/latest-object/:tokenId',
|
|
37
|
+
queryParams: {
|
|
38
|
+
after: false,
|
|
39
|
+
before: false,
|
|
40
|
+
id: false,
|
|
41
|
+
limit: false,
|
|
42
|
+
producer: false,
|
|
43
|
+
source: false,
|
|
44
|
+
type: false
|
|
45
|
+
},
|
|
46
|
+
auth: 'vehicle_jwt'
|
|
47
|
+
},
|
|
48
|
+
getObjects: {
|
|
49
|
+
method: 'GET',
|
|
50
|
+
path: '/v1/vehicle/objects/:tokenId',
|
|
51
|
+
queryParams: {
|
|
52
|
+
after: false,
|
|
53
|
+
before: false,
|
|
54
|
+
id: false,
|
|
55
|
+
limit: false,
|
|
56
|
+
producer: false,
|
|
57
|
+
source: false,
|
|
58
|
+
type: false
|
|
59
|
+
},
|
|
60
|
+
auth: 'vehicle_jwt'
|
|
61
|
+
}
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
}
|
package/dist/cjs/index.js
CHANGED
|
@@ -20164,11 +20164,13 @@ const {
|
|
|
20164
20164
|
/** @format */
|
|
20165
20165
|
const DimoEnvironment = {
|
|
20166
20166
|
Production: {
|
|
20167
|
+
Agents: 'https://agents.dimo.zone',
|
|
20167
20168
|
Attestation: 'https://attestation-api.dimo.zone',
|
|
20168
20169
|
Auth: 'https://auth.dimo.zone',
|
|
20169
20170
|
Identity: 'https://identity-api.dimo.zone/query',
|
|
20170
20171
|
Devices: 'https://devices-api.dimo.zone',
|
|
20171
20172
|
DeviceDefinitions: 'https://device-definitions-api.dimo.zone',
|
|
20173
|
+
Fetch: 'https://fetch-api.dimo.zone',
|
|
20172
20174
|
Telemetry: 'https://telemetry-api.dimo.zone/query',
|
|
20173
20175
|
TokenExchange: 'https://token-exchange-api.dimo.zone',
|
|
20174
20176
|
Trips: 'https://trips-api.dimo.zone',
|
|
@@ -20177,11 +20179,13 @@ const DimoEnvironment = {
|
|
|
20177
20179
|
VehicleTriggers: 'https://vehicle-triggers-api.dimo.zone',
|
|
20178
20180
|
},
|
|
20179
20181
|
Dev: {
|
|
20182
|
+
Agents: 'https://agents.dev.dimo.zone',
|
|
20180
20183
|
Attestation: 'https://attestation-api.dev.dimo.zone',
|
|
20181
20184
|
Auth: 'https://auth.dev.dimo.zone',
|
|
20182
20185
|
Identity: 'https://identity-api.dev.dimo.zone/query',
|
|
20183
20186
|
Devices: 'https://devices-api.dev.dimo.zone',
|
|
20184
20187
|
DeviceDefinitions: 'https://device-definitions-api.dev.dimo.zone',
|
|
20188
|
+
Fetch: 'https://fetch-api.dev.dimo.zone',
|
|
20185
20189
|
Telemetry: 'https://telemetry-api.dev.dimo.zone/query',
|
|
20186
20190
|
TokenExchange: 'https://token-exchange-api.dev.dimo.zone',
|
|
20187
20191
|
Trips: 'https://trips-api.dev.dimo.zone',
|
|
@@ -20632,10 +20636,12 @@ class Telemetry extends Resource$1 {
|
|
|
20632
20636
|
/** @format */
|
|
20633
20637
|
// import { Stream } from './streamr';
|
|
20634
20638
|
class DIMO {
|
|
20639
|
+
agents;
|
|
20635
20640
|
attestation;
|
|
20636
20641
|
auth;
|
|
20637
20642
|
devicedefinitions;
|
|
20638
20643
|
devices;
|
|
20644
|
+
fetch;
|
|
20639
20645
|
identity;
|
|
20640
20646
|
telemetry;
|
|
20641
20647
|
tokenexchange;
|
|
@@ -20648,10 +20654,12 @@ class DIMO {
|
|
|
20648
20654
|
/**
|
|
20649
20655
|
* Set up all REST Endpoints
|
|
20650
20656
|
*/
|
|
20657
|
+
this.agents = new Agents(DimoEnvironment[env].Agents, env);
|
|
20651
20658
|
this.attestation = new Attestation(DimoEnvironment[env].Attestation, env);
|
|
20652
20659
|
this.auth = new Auth(DimoEnvironment[env].Auth, env);
|
|
20653
20660
|
this.devicedefinitions = new DeviceDefinitions(DimoEnvironment[env].DeviceDefinitions, env);
|
|
20654
20661
|
this.devices = new Devices(DimoEnvironment[env].Devices, env);
|
|
20662
|
+
this.fetch = new Fetch(DimoEnvironment[env].Fetch, env);
|
|
20655
20663
|
this.tokenexchange = new TokenExchange(DimoEnvironment[env].TokenExchange, env);
|
|
20656
20664
|
this.trips = new Trips(DimoEnvironment[env].Trips, env);
|
|
20657
20665
|
this.valuations = new Valuations(DimoEnvironment[env].Valuations, env);
|
|
@@ -142422,14 +142430,19 @@ const Method = async (resource, baseUrl, params = {}, env) => {
|
|
|
142422
142430
|
let body = {};
|
|
142423
142431
|
if (resource.body) {
|
|
142424
142432
|
for (const key in resource.body) {
|
|
142425
|
-
if (
|
|
142433
|
+
if (resource.body[key] === true) {
|
|
142434
|
+
// Required field
|
|
142426
142435
|
if (!params[key]) {
|
|
142427
142436
|
console.error(`Missing required body parameter: ${key}`);
|
|
142428
142437
|
throw new DimoError({
|
|
142429
142438
|
message: `Missing required body parameter: ${key}`
|
|
142430
142439
|
});
|
|
142431
142440
|
}
|
|
142432
|
-
|
|
142441
|
+
body[key] = params[key];
|
|
142442
|
+
}
|
|
142443
|
+
else if (resource.body[key] === false) {
|
|
142444
|
+
// Optional field - include only if provided
|
|
142445
|
+
if (params[key] !== undefined) {
|
|
142433
142446
|
body[key] = params[key];
|
|
142434
142447
|
}
|
|
142435
142448
|
}
|
|
@@ -142487,6 +142500,69 @@ class Resource {
|
|
|
142487
142500
|
}
|
|
142488
142501
|
}
|
|
142489
142502
|
|
|
142503
|
+
class Agents extends Resource {
|
|
142504
|
+
constructor(api, env) {
|
|
142505
|
+
super(api, 'Agents', env);
|
|
142506
|
+
this.setResource({
|
|
142507
|
+
healthCheck: {
|
|
142508
|
+
method: 'GET',
|
|
142509
|
+
path: '/'
|
|
142510
|
+
},
|
|
142511
|
+
createAgent: {
|
|
142512
|
+
method: 'POST',
|
|
142513
|
+
path: '/agents',
|
|
142514
|
+
body: {
|
|
142515
|
+
'type': false,
|
|
142516
|
+
'personality': false,
|
|
142517
|
+
'secrets': true,
|
|
142518
|
+
'variables': true,
|
|
142519
|
+
},
|
|
142520
|
+
auth: 'developer_jwt'
|
|
142521
|
+
},
|
|
142522
|
+
deleteAgent: {
|
|
142523
|
+
method: 'DELETE',
|
|
142524
|
+
path: '/agents/:agentId',
|
|
142525
|
+
auth: 'developer_jwt'
|
|
142526
|
+
},
|
|
142527
|
+
sendMessage: {
|
|
142528
|
+
method: 'POST',
|
|
142529
|
+
path: '/agents/:agentId/message',
|
|
142530
|
+
body: {
|
|
142531
|
+
'message': true,
|
|
142532
|
+
'vehicleIds': false,
|
|
142533
|
+
'user': false
|
|
142534
|
+
},
|
|
142535
|
+
auth: 'developer_jwt'
|
|
142536
|
+
},
|
|
142537
|
+
streamMessage: {
|
|
142538
|
+
method: 'POST',
|
|
142539
|
+
path: '/agents/:agentId/stream',
|
|
142540
|
+
body: {
|
|
142541
|
+
'message': true,
|
|
142542
|
+
'vehicleIds': false,
|
|
142543
|
+
'user': false
|
|
142544
|
+
},
|
|
142545
|
+
auth: 'developer_jwt'
|
|
142546
|
+
},
|
|
142547
|
+
getHistory: {
|
|
142548
|
+
method: 'GET',
|
|
142549
|
+
path: '/agents/:agentId/history',
|
|
142550
|
+
queryParams: {
|
|
142551
|
+
'limit': false
|
|
142552
|
+
},
|
|
142553
|
+
auth: 'developer_jwt'
|
|
142554
|
+
}
|
|
142555
|
+
});
|
|
142556
|
+
const originalCreateAgent = this.createAgent;
|
|
142557
|
+
this.createAgent = (params = {}) => {
|
|
142558
|
+
return originalCreateAgent({
|
|
142559
|
+
type: 'driver_agent_v1',
|
|
142560
|
+
...params
|
|
142561
|
+
});
|
|
142562
|
+
};
|
|
142563
|
+
}
|
|
142564
|
+
}
|
|
142565
|
+
|
|
142490
142566
|
class Attestation extends Resource {
|
|
142491
142567
|
constructor(api, env) {
|
|
142492
142568
|
super(api, 'Attestation', env);
|
|
@@ -142603,6 +142679,70 @@ class Devices extends Resource {
|
|
|
142603
142679
|
}
|
|
142604
142680
|
}
|
|
142605
142681
|
|
|
142682
|
+
class Fetch extends Resource {
|
|
142683
|
+
constructor(api, env) {
|
|
142684
|
+
super(api, 'Fetch', env);
|
|
142685
|
+
this.setResource({
|
|
142686
|
+
getIndexKeys: {
|
|
142687
|
+
method: 'GET',
|
|
142688
|
+
path: '/v1/vehicle/index-keys/:tokenId',
|
|
142689
|
+
queryParams: {
|
|
142690
|
+
after: false,
|
|
142691
|
+
before: false,
|
|
142692
|
+
id: false,
|
|
142693
|
+
limit: false,
|
|
142694
|
+
producer: false,
|
|
142695
|
+
source: false,
|
|
142696
|
+
type: false
|
|
142697
|
+
},
|
|
142698
|
+
auth: 'vehicle_jwt'
|
|
142699
|
+
},
|
|
142700
|
+
getLatestIndexKey: {
|
|
142701
|
+
method: 'GET',
|
|
142702
|
+
path: '/v1/vehicle/latest-index-key/:tokenId',
|
|
142703
|
+
queryParams: {
|
|
142704
|
+
after: false,
|
|
142705
|
+
before: false,
|
|
142706
|
+
id: false,
|
|
142707
|
+
limit: false,
|
|
142708
|
+
producer: false,
|
|
142709
|
+
source: false,
|
|
142710
|
+
type: false
|
|
142711
|
+
},
|
|
142712
|
+
auth: 'vehicle_jwt'
|
|
142713
|
+
},
|
|
142714
|
+
getLatestObject: {
|
|
142715
|
+
method: 'GET',
|
|
142716
|
+
path: '/v1/vehicle/latest-object/:tokenId',
|
|
142717
|
+
queryParams: {
|
|
142718
|
+
after: false,
|
|
142719
|
+
before: false,
|
|
142720
|
+
id: false,
|
|
142721
|
+
limit: false,
|
|
142722
|
+
producer: false,
|
|
142723
|
+
source: false,
|
|
142724
|
+
type: false
|
|
142725
|
+
},
|
|
142726
|
+
auth: 'vehicle_jwt'
|
|
142727
|
+
},
|
|
142728
|
+
getObjects: {
|
|
142729
|
+
method: 'GET',
|
|
142730
|
+
path: '/v1/vehicle/objects/:tokenId',
|
|
142731
|
+
queryParams: {
|
|
142732
|
+
after: false,
|
|
142733
|
+
before: false,
|
|
142734
|
+
id: false,
|
|
142735
|
+
limit: false,
|
|
142736
|
+
producer: false,
|
|
142737
|
+
source: false,
|
|
142738
|
+
type: false
|
|
142739
|
+
},
|
|
142740
|
+
auth: 'vehicle_jwt'
|
|
142741
|
+
}
|
|
142742
|
+
});
|
|
142743
|
+
}
|
|
142744
|
+
}
|
|
142745
|
+
|
|
142606
142746
|
class TokenExchange extends Resource {
|
|
142607
142747
|
constructor(api, env) {
|
|
142608
142748
|
super(api, 'TokenExchange', env);
|
|
@@ -142743,6 +142883,7 @@ class VehicleTriggers extends Resource {
|
|
|
142743
142883
|
}
|
|
142744
142884
|
}
|
|
142745
142885
|
|
|
142886
|
+
exports.Agents = Agents;
|
|
142746
142887
|
exports.Attestation = Attestation;
|
|
142747
142888
|
exports.Auth = Auth;
|
|
142748
142889
|
exports.DIMO = DIMO;
|
|
@@ -142751,6 +142892,7 @@ exports.Devices = Devices;
|
|
|
142751
142892
|
exports.DimoConstants = DimoConstants;
|
|
142752
142893
|
exports.DimoEnvironment = DimoEnvironment;
|
|
142753
142894
|
exports.DimoError = DimoError;
|
|
142895
|
+
exports.Fetch = Fetch;
|
|
142754
142896
|
exports.Identity = Identity;
|
|
142755
142897
|
exports.Telemetry = Telemetry;
|
|
142756
142898
|
exports.TokenExchange = TokenExchange;
|