@mitosislabs/sdk 0.1.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 +123 -0
- package/dist/api/agents.d.ts +24 -0
- package/dist/api/agents.d.ts.map +1 -0
- package/dist/api/agents.js +48 -0
- package/dist/api/agents.js.map +1 -0
- package/dist/api/integrations.d.ts +11 -0
- package/dist/api/integrations.d.ts.map +1 -0
- package/dist/api/integrations.js +22 -0
- package/dist/api/integrations.js.map +1 -0
- package/dist/api/offices.d.ts +16 -0
- package/dist/api/offices.d.ts.map +1 -0
- package/dist/api/offices.js +35 -0
- package/dist/api/offices.js.map +1 -0
- package/dist/auth/index.d.ts +5 -0
- package/dist/auth/index.d.ts.map +1 -0
- package/dist/auth/index.js +21 -0
- package/dist/auth/index.js.map +1 -0
- package/dist/cli/index.d.ts +3 -0
- package/dist/cli/index.d.ts.map +1 -0
- package/dist/cli/index.js +229 -0
- package/dist/cli/index.js.map +1 -0
- package/dist/client.d.ts +29 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +41 -0
- package/dist/client.js.map +1 -0
- package/dist/index.d.ts +7 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/transport.d.ts +18 -0
- package/dist/transport.d.ts.map +1 -0
- package/dist/transport.js +88 -0
- package/dist/transport.js.map +1 -0
- package/dist/types/index.d.ts +104 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +13 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +37 -0
package/README.md
ADDED
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
# OS-1 SDK
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the [OS-1](https://mitosislabs.ai) platform. Manage offices, agents, and integrations programmatically.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @os1/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Quick Start
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { OS1Client } from '@os1/sdk';
|
|
15
|
+
|
|
16
|
+
const client = new OS1Client({
|
|
17
|
+
endpoint: 'https://api.mitosislabs.ai',
|
|
18
|
+
apiKey: process.env.OS1_API_KEY,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
// List your offices
|
|
22
|
+
const offices = await client.offices.list();
|
|
23
|
+
|
|
24
|
+
// Hire an agent
|
|
25
|
+
const agent = await client.agents.hire(offices[0].id, {
|
|
26
|
+
name: 'aria',
|
|
27
|
+
role: 'researcher',
|
|
28
|
+
modelTier: 'opus',
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
// Fetch the created agent
|
|
32
|
+
const created = await client.agents.get(offices[0].id, 'aria');
|
|
33
|
+
console.log(created.name);
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Authentication
|
|
37
|
+
|
|
38
|
+
Get your API key from the [OS-1 dashboard](https://mitosislabs.ai/dashboard/settings).
|
|
39
|
+
|
|
40
|
+
```typescript
|
|
41
|
+
const client = new OS1Client({
|
|
42
|
+
endpoint: 'https://api.mitosislabs.ai',
|
|
43
|
+
auth: { type: 'apiKey', key: 'os1_...' },
|
|
44
|
+
});
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
Or use the CLI to save credentials or run the OAuth device flow:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
os1 init --endpoint https://api.mitosislabs.ai --key os1_...
|
|
51
|
+
os1 login api-key --key os1_...
|
|
52
|
+
os1 login device # prints a URL + code you approve in the dashboard
|
|
53
|
+
os1 auth-test
|
|
54
|
+
os1 offices list
|
|
55
|
+
os1 agents list --office <id>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
## API
|
|
59
|
+
|
|
60
|
+
### Offices
|
|
61
|
+
|
|
62
|
+
```typescript
|
|
63
|
+
client.offices.list()
|
|
64
|
+
client.offices.create({ name: 'my-office' })
|
|
65
|
+
client.offices.get(officeId)
|
|
66
|
+
client.offices.status(officeId)
|
|
67
|
+
client.offices.delete(officeId)
|
|
68
|
+
client.offices.suspend(officeId)
|
|
69
|
+
client.offices.resume(officeId)
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### Agents
|
|
73
|
+
|
|
74
|
+
```typescript
|
|
75
|
+
client.agents.hire(officeId, { name, role?, modelTier?, skills? })
|
|
76
|
+
client.agents.list(officeId)
|
|
77
|
+
client.agents.get(officeId, name)
|
|
78
|
+
client.agents.update(officeId, name, { role?, modelTier?, skills? })
|
|
79
|
+
client.agents.fire(officeId, name)
|
|
80
|
+
client.agents.logs(officeId, name)
|
|
81
|
+
client.agents.activity(officeId, name, { limit?, category? })
|
|
82
|
+
client.agents.promote(officeId, name, { modelTier })
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
### Integrations
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
client.integrations.listModels(officeId)
|
|
89
|
+
client.integrations.setSecret(officeId, integrationId, key)
|
|
90
|
+
client.integrations.deleteSecret(officeId, integrationId)
|
|
91
|
+
client.integrations.toggleAgent(officeId, integrationId, agentName, enabled)
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
## CLI
|
|
95
|
+
|
|
96
|
+
```bash
|
|
97
|
+
# Credentials
|
|
98
|
+
os1 init --endpoint https://api.mitosislabs.ai --key <api-key>
|
|
99
|
+
os1 login api-key --key <api-key>
|
|
100
|
+
os1 login device
|
|
101
|
+
os1 logout
|
|
102
|
+
os1 auth-test
|
|
103
|
+
|
|
104
|
+
# Offices
|
|
105
|
+
os1 offices list
|
|
106
|
+
os1 offices create --name "my-office"
|
|
107
|
+
os1 offices status <officeId>
|
|
108
|
+
os1 offices delete <officeId>
|
|
109
|
+
|
|
110
|
+
# Agents
|
|
111
|
+
os1 agents list --office <officeId>
|
|
112
|
+
os1 agents hire --office <officeId> --name "aria" --model opus
|
|
113
|
+
os1 agents get <officeId> aria
|
|
114
|
+
os1 agents fire <officeId> aria
|
|
115
|
+
os1 agents logs <officeId> aria
|
|
116
|
+
|
|
117
|
+
# Raw API
|
|
118
|
+
os1 api GET /api/v1/offices
|
|
119
|
+
```
|
|
120
|
+
|
|
121
|
+
## License
|
|
122
|
+
|
|
123
|
+
MIT
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Transport } from '../transport.js';
|
|
2
|
+
import type { Agent, HireAgentRequest, UpdateAgentRequest, PromoteRequest, SkillsRequest, AgentLogs, ActivityEvent, ActivityQuery } from '../types/index.js';
|
|
3
|
+
export declare class AgentsAPI {
|
|
4
|
+
private transport;
|
|
5
|
+
constructor(transport: Transport);
|
|
6
|
+
hire(officeId: string, req: HireAgentRequest): Promise<Agent>;
|
|
7
|
+
list(officeId: string): Promise<Agent[]>;
|
|
8
|
+
get(officeId: string, name: string): Promise<Agent>;
|
|
9
|
+
update(officeId: string, name: string, req: UpdateAgentRequest): Promise<Agent>;
|
|
10
|
+
fire(officeId: string, name: string): Promise<void>;
|
|
11
|
+
logs(officeId: string, name: string, opts?: {
|
|
12
|
+
tail?: number;
|
|
13
|
+
}): Promise<AgentLogs>;
|
|
14
|
+
activity(officeId: string, name: string, query?: ActivityQuery): Promise<ActivityEvent[]>;
|
|
15
|
+
promote(officeId: string, name: string, req: PromoteRequest): Promise<Agent>;
|
|
16
|
+
setSkills(officeId: string, name: string, req: SkillsRequest): Promise<Agent>;
|
|
17
|
+
archive(officeId: string, name: string): Promise<void>;
|
|
18
|
+
restore(officeId: string, name: string): Promise<void>;
|
|
19
|
+
presence(officeId: string, name: string): Promise<{
|
|
20
|
+
online: boolean;
|
|
21
|
+
last_seen?: string;
|
|
22
|
+
}>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=agents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.d.ts","sourceRoot":"","sources":["../../src/api/agents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,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AAC;IAI7E,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAItD,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,MAAM,EAAE,OAAO,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;CAGjG"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
function base(officeId) {
|
|
2
|
+
return `/api/v1/offices/${officeId}/employees`;
|
|
3
|
+
}
|
|
4
|
+
export class AgentsAPI {
|
|
5
|
+
transport;
|
|
6
|
+
constructor(transport) {
|
|
7
|
+
this.transport = transport;
|
|
8
|
+
}
|
|
9
|
+
async hire(officeId, req) {
|
|
10
|
+
return this.transport.post(base(officeId), req);
|
|
11
|
+
}
|
|
12
|
+
async list(officeId) {
|
|
13
|
+
return this.transport.get(base(officeId));
|
|
14
|
+
}
|
|
15
|
+
async get(officeId, name) {
|
|
16
|
+
return this.transport.get(`${base(officeId)}/${name}`);
|
|
17
|
+
}
|
|
18
|
+
async update(officeId, name, req) {
|
|
19
|
+
return this.transport.patch(`${base(officeId)}/${name}`, req);
|
|
20
|
+
}
|
|
21
|
+
async fire(officeId, name) {
|
|
22
|
+
await this.transport.delete(`${base(officeId)}/${name}`);
|
|
23
|
+
}
|
|
24
|
+
async logs(officeId, name, opts) {
|
|
25
|
+
return this.transport.get(`${base(officeId)}/${name}/logs`, {
|
|
26
|
+
tail: opts?.tail,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
async activity(officeId, name, query) {
|
|
30
|
+
return this.transport.get(`${base(officeId)}/${name}/activity`, query);
|
|
31
|
+
}
|
|
32
|
+
async promote(officeId, name, req) {
|
|
33
|
+
return this.transport.post(`${base(officeId)}/${name}/promote`, req);
|
|
34
|
+
}
|
|
35
|
+
async setSkills(officeId, name, req) {
|
|
36
|
+
return this.transport.post(`${base(officeId)}/${name}/skills`, req);
|
|
37
|
+
}
|
|
38
|
+
async archive(officeId, name) {
|
|
39
|
+
await this.transport.post(`${base(officeId)}/${name}/archive`);
|
|
40
|
+
}
|
|
41
|
+
async restore(officeId, name) {
|
|
42
|
+
await this.transport.post(`${base(officeId)}/${name}/restore`);
|
|
43
|
+
}
|
|
44
|
+
async presence(officeId, name) {
|
|
45
|
+
return this.transport.get(`${base(officeId)}/${name}/presence`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=agents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agents.js","sourceRoot":"","sources":["../../src/api/agents.ts"],"names":[],"mappings":"AAYA,SAAS,IAAI,CAAC,QAAgB;IAC5B,OAAO,mBAAmB,QAAQ,YAAY,CAAC;AACjD,CAAC;AAED,MAAM,OAAO,SAAS;IACA;IAApB,YAAoB,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAE5C,KAAK,CAAC,IAAI,CAAC,QAAgB,EAAE,GAAqB;QAChD,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAQ,IAAI,CAAC,QAAQ,CAAC,EAAE,GAAG,CAAC,CAAC;IACzD,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,QAAgB;QACzB,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAU,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;IACrD,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,QAAgB,EAAE,IAAY;QACtC,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAQ,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC;IAChE,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,QAAgB,EAAE,IAAY,EAAE,GAAuB;QA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AI,CAAC,QAAQ,CAAC,IAAI,IAAI,UAAU,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,QAAgB,EAAE,IAAY;QAC1C,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,UAAU,CAAC,CAAC;IACjE,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,QAAgB,EAAE,IAAY;QAC3C,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,IAAI,IAAI,WAAW,CAAC,CAAC;IAClE,CAAC;CACF"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Transport } from '../transport.js';
|
|
2
|
+
import type { ModelInfo } from '../types/index.js';
|
|
3
|
+
export declare class IntegrationsAPI {
|
|
4
|
+
private transport;
|
|
5
|
+
constructor(transport: Transport);
|
|
6
|
+
listModels(officeId: string): Promise<ModelInfo[]>;
|
|
7
|
+
setSecret(officeId: string, integrationId: string, key: string): Promise<void>;
|
|
8
|
+
deleteSecret(officeId: string, integrationId: string): Promise<void>;
|
|
9
|
+
toggleAgent(officeId: string, integrationId: string, agentName: string, enabled: boolean): Promise<void>;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=integrations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrations.d.ts","sourceRoot":"","sources":["../../src/api/integrations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAMnD,qBAAa,eAAe;IACd,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAElC,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAIlD,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAI9E,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIpE,WAAW,CAAC,QAAQ,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC;CAG/G"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
function base(officeId) {
|
|
2
|
+
return `/api/v1/offices/${officeId}`;
|
|
3
|
+
}
|
|
4
|
+
export class IntegrationsAPI {
|
|
5
|
+
transport;
|
|
6
|
+
constructor(transport) {
|
|
7
|
+
this.transport = transport;
|
|
8
|
+
}
|
|
9
|
+
async listModels(officeId) {
|
|
10
|
+
return this.transport.get(`${base(officeId)}/provider-models`);
|
|
11
|
+
}
|
|
12
|
+
async setSecret(officeId, integrationId, key) {
|
|
13
|
+
await this.transport.post(`${base(officeId)}/integrations/${integrationId}/secret`, { key });
|
|
14
|
+
}
|
|
15
|
+
async deleteSecret(officeId, integrationId) {
|
|
16
|
+
await this.transport.delete(`${base(officeId)}/integrations/${integrationId}/secret`);
|
|
17
|
+
}
|
|
18
|
+
async toggleAgent(officeId, integrationId, agentName, enabled) {
|
|
19
|
+
await this.transport.post(`${base(officeId)}/integrations/${integrationId}/agents/${agentName}`, { enabled });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=integrations.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"integrations.js","sourceRoot":"","sources":["../../src/api/integrations.ts"],"names":[],"mappings":"AAGA,SAAS,IAAI,CAAC,QAAgB;IAC5B,OAAO,mBAAmB,QAAQ,EAAE,CAAC;AACvC,CAAC;AAED,MAAM,OAAO,eAAe;IACN;IAApB,YAAoB,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAE5C,KAAK,CAAC,UAAU,CAAC,QAAgB;QAC/B,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAc,GAAG,IAAI,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC;IAC9E,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,QAAgB,EAAE,aAAqB,EAAE,GAAW;QAClE,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,aAAa,SAAS,EAAE,EAAE,GAAG,EAAE,CAAC,CAAC;IAC/F,CAAC;IAED,KAAK,CAAC,YAAY,CAAC,QAAgB,EAAE,aAAqB;QACxD,MAAM,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,aAAa,SAAS,CAAC,CAAC;IACxF,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,QAAgB,EAAE,aAAqB,EAAE,SAAiB,EAAE,OAAgB;QAC5F,MAAM,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,QAAQ,CAAC,iBAAiB,aAAa,WAAW,SAAS,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,CAAC;IAChH,CAAC;CACF"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { Transport } from '../transport.js';
|
|
2
|
+
import type { Office, CreateOfficeRequest, OfficeSettings, ClusterStatus } from '../types/index.js';
|
|
3
|
+
export declare class OfficesAPI {
|
|
4
|
+
private transport;
|
|
5
|
+
constructor(transport: Transport);
|
|
6
|
+
list(): Promise<Office[]>;
|
|
7
|
+
create(req: CreateOfficeRequest): Promise<Office>;
|
|
8
|
+
get(officeId: string): Promise<Office>;
|
|
9
|
+
status(officeId: string): Promise<ClusterStatus>;
|
|
10
|
+
getSettings(officeId: string): Promise<OfficeSettings>;
|
|
11
|
+
updateSettings(officeId: string, settings: Partial<OfficeSettings>): Promise<OfficeSettings>;
|
|
12
|
+
delete(officeId: string): Promise<void>;
|
|
13
|
+
suspend(officeId: string): Promise<void>;
|
|
14
|
+
resume(officeId: string): Promise<void>;
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=offices.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offices.d.ts","sourceRoot":"","sources":["../../src/api/offices.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,KAAK,EAAE,MAAM,EAAE,mBAAmB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAIpG,qBAAa,UAAU;IACT,OAAO,CAAC,SAAS;gBAAT,SAAS,EAAE,SAAS;IAElC,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;IAIzB,MAAM,CAAC,GAAG,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAIjD,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAItC,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,CAAC;IAIhD,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAItD,cAAc,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,cAAc,CAAC,GAAG,OAAO,CAAC,cAAc,CAAC;IAI5F,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIvC,OAAO,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxC,MAAM,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG9C"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
const BASE = '/api/v1/offices';
|
|
2
|
+
export class OfficesAPI {
|
|
3
|
+
transport;
|
|
4
|
+
constructor(transport) {
|
|
5
|
+
this.transport = transport;
|
|
6
|
+
}
|
|
7
|
+
async list() {
|
|
8
|
+
return this.transport.get(BASE);
|
|
9
|
+
}
|
|
10
|
+
async create(req) {
|
|
11
|
+
return this.transport.post(BASE, req);
|
|
12
|
+
}
|
|
13
|
+
async get(officeId) {
|
|
14
|
+
return this.transport.get(`${BASE}/${officeId}`);
|
|
15
|
+
}
|
|
16
|
+
async status(officeId) {
|
|
17
|
+
return this.transport.get(`${BASE}/${officeId}/status`);
|
|
18
|
+
}
|
|
19
|
+
async getSettings(officeId) {
|
|
20
|
+
return this.transport.get(`${BASE}/${officeId}/settings`);
|
|
21
|
+
}
|
|
22
|
+
async updateSettings(officeId, settings) {
|
|
23
|
+
return this.transport.patch(`${BASE}/${officeId}/settings`, settings);
|
|
24
|
+
}
|
|
25
|
+
async delete(officeId) {
|
|
26
|
+
await this.transport.delete(`${BASE}/${officeId}`);
|
|
27
|
+
}
|
|
28
|
+
async suspend(officeId) {
|
|
29
|
+
await this.transport.post(`${BASE}/${officeId}/suspend`);
|
|
30
|
+
}
|
|
31
|
+
async resume(officeId) {
|
|
32
|
+
await this.transport.post(`${BASE}/${officeId}/resume`);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
//# sourceMappingURL=offices.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offices.js","sourceRoot":"","sources":["../../src/api/offices.ts"],"names":[],"mappings":"AAGA,MAAM,IAAI,GAAG,iBAAiB,CAAC;AAE/B,MAAM,OAAO,UAAU;IACD;IAApB,YAAoB,SAAoB;QAApB,cAAS,GAAT,SAAS,CAAW;IAAG,CAAC;IAE5C,KAAK,CAAC,IAAI;QACR,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAW,IAAI,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,GAAwB;QACnC,OAAO,IAAI,CAAC,SAAS,CAAC,I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M,EAAE,MAAM,CAAC,EAAE,MAAM,GAAG,MAAM,CAYtE"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { createHmac } from 'node:crypto';
|
|
2
|
+
/**
|
|
3
|
+
* Generate an authorization header from an API key.
|
|
4
|
+
*/
|
|
5
|
+
export function makeAuthHeader(apiKey, userId) {
|
|
6
|
+
const now = Math.floor(Date.now() / 1000);
|
|
7
|
+
const header = b64url(Buffer.from(JSON.stringify({ alg: 'HS256', typ: 'JWT' })));
|
|
8
|
+
const payload = b64url(Buffer.from(JSON.stringify({
|
|
9
|
+
botId: '',
|
|
10
|
+
userId: userId ?? '',
|
|
11
|
+
privateIp: 'k8s',
|
|
12
|
+
iat: now,
|
|
13
|
+
exp: now + 3600,
|
|
14
|
+
})));
|
|
15
|
+
const sig = b64url(createHmac('sha256', apiKey).update(`${header}.${payload}`).digest());
|
|
16
|
+
return `Bearer ${header}.${payload}.${sig}`;
|
|
17
|
+
}
|
|
18
|
+
function b64url(buf) {
|
|
19
|
+
return buf.toString('base64').replace(/=/g, '').replace(/\+/g, '-').replace(/\//g, '_');
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAEzC;;GAEG;AACH,MAAM,UAAU,cAAc,CAAC,MAAc,EAAE,MAAe;IAC5D,MAAM,GAAG,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,GAAG,EAAE,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,CAAC;IACjF,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC;QAChD,KAAK,EAAE,EAAE;QACT,MAAM,EAAE,MAAM,IAAI,EAAE;QACpB,SAAS,EAAE,KAAK;QAChB,GAAG,EAAE,GAAG;QACR,GAAG,EAAE,GAAG,GAAG,IAAI;KAChB,CAAC,CAAC,CAAC,CAAC;IACL,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,GAAG,MAAM,IAAI,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,CAAC;IACzF,OAAO,UAAU,MAAM,IAAI,OAAO,IAAI,GAAG,EAAE,CAAC;AAC9C,CAAC;AAED,SAAS,MAAM,CAAC,GAAW;IACzB,OAAO,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,CAAC;AAC1F,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/cli/index.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { Command } from 'commander';
|
|
3
|
+
import { OS1Client } from '../client.js';
|
|
4
|
+
import { readFileSync, writeFileSync, mkdirSync, existsSync, unlinkSync } from 'node:fs';
|
|
5
|
+
import { join } from 'node:path';
|
|
6
|
+
import { homedir } from 'node:os';
|
|
7
|
+
import { createInterface } from 'node:readline';
|
|
8
|
+
const program = new Command();
|
|
9
|
+
const CONFIG_DIR = join(homedir(), '.os1');
|
|
10
|
+
const CONFIG_FILE = join(CONFIG_DIR, 'config.json');
|
|
11
|
+
program
|
|
12
|
+
.name('os1')
|
|
13
|
+
.description('OS-1 SDK — manage offices, agents, and integrations')
|
|
14
|
+
.version('0.1.0');
|
|
15
|
+
function die(msg) {
|
|
16
|
+
console.error(`error: ${msg}`);
|
|
17
|
+
process.exit(1);
|
|
18
|
+
}
|
|
19
|
+
function ensureConfigDir() {
|
|
20
|
+
mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
|
|
21
|
+
}
|
|
22
|
+
function peekConfig() {
|
|
23
|
+
if (!existsSync(CONFIG_FILE))
|
|
24
|
+
return null;
|
|
25
|
+
return JSON.parse(readFileSync(CONFIG_FILE, 'utf-8'));
|
|
26
|
+
}
|
|
27
|
+
function loadConfig() {
|
|
28
|
+
const config = peekConfig();
|
|
29
|
+
if (!config)
|
|
30
|
+
die(`Not configured. Run 'os1 init' first.`);
|
|
31
|
+
return config;
|
|
32
|
+
}
|
|
33
|
+
function saveConfig(config) {
|
|
34
|
+
ensureConfigDir();
|
|
35
|
+
writeFileSync(CONFIG_FILE, JSON.stringify(config, null, 2), { mode: 0o600 });
|
|
36
|
+
}
|
|
37
|
+
function getClient() {
|
|
38
|
+
const config = loadConfig();
|
|
39
|
+
return new OS1Client({ endpoint: config.endpoint, auth: config.auth });
|
|
40
|
+
}
|
|
41
|
+
function json(data) {
|
|
42
|
+
console.log(JSON.stringify(data, null, 2));
|
|
43
|
+
}
|
|
44
|
+
function apiKeyAuth(key, userId) {
|
|
45
|
+
return { type: 'apiKey', key: key.trim(), userId };
|
|
46
|
+
}
|
|
47
|
+
function tokenAuth(token) {
|
|
48
|
+
return { type: 'token', token };
|
|
49
|
+
}
|
|
50
|
+
function sleep(ms) {
|
|
51
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
52
|
+
}
|
|
53
|
+
async function requestDeviceCode(endpoint) {
|
|
54
|
+
const resp = await fetch(`${endpoint.replace(/\/$/, '')}/oauth/device`, {
|
|
55
|
+
method: 'POST',
|
|
56
|
+
headers: { 'Content-Type': 'application/json' },
|
|
57
|
+
});
|
|
58
|
+
if (!resp.ok)
|
|
59
|
+
throw new Error(`Device flow failed (${resp.status})`);
|
|
60
|
+
return resp.json();
|
|
61
|
+
}
|
|
62
|
+
async function pollDeviceToken(endpoint, deviceCode, interval) {
|
|
63
|
+
const url = `${endpoint.replace(/\/$/, '')}/oauth/device/token`;
|
|
64
|
+
while (true) {
|
|
65
|
+
await sleep(interval * 1000);
|
|
66
|
+
const resp = await fetch(url, {
|
|
67
|
+
method: 'POST',
|
|
68
|
+
headers: { 'Content-Type': 'application/json' },
|
|
69
|
+
body: JSON.stringify({ device_code: deviceCode }),
|
|
70
|
+
});
|
|
71
|
+
if (resp.status === 200) {
|
|
72
|
+
const payload = await resp.json();
|
|
73
|
+
return payload.access_token;
|
|
74
|
+
}
|
|
75
|
+
const err = await resp.json().catch(() => ({}));
|
|
76
|
+
const errorCode = err.error;
|
|
77
|
+
if (errorCode === 'authorization_pending')
|
|
78
|
+
continue;
|
|
79
|
+
if (errorCode === 'slow_down') {
|
|
80
|
+
interval += 5;
|
|
81
|
+
continue;
|
|
82
|
+
}
|
|
83
|
+
throw new Error(err?.error_description ??
|
|
84
|
+
err?.error ??
|
|
85
|
+
`Device token request failed with status ${resp.status}`);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const DEFAULT_ENDPOINT = 'https://api.mitosislabs.ai';
|
|
89
|
+
program
|
|
90
|
+
.command('init')
|
|
91
|
+
.description('Configure the OS-1 SDK')
|
|
92
|
+
.option('-e, --endpoint <url>', 'API endpoint', DEFAULT_ENDPOINT)
|
|
93
|
+
.option('-k, --key <apiKey>', 'API key')
|
|
94
|
+
.option('-u, --user <userId>', 'User ID')
|
|
95
|
+
.action(async (opts) => {
|
|
96
|
+
let apiKey = opts.key;
|
|
97
|
+
if (!apiKey) {
|
|
98
|
+
const rl = createInterface({ input: process.stdin, output: process.stdout });
|
|
99
|
+
apiKey = await new Promise((resolve) => {
|
|
100
|
+
rl.question('API key: ', (answer) => {
|
|
101
|
+
rl.close();
|
|
102
|
+
resolve(answer.trim());
|
|
103
|
+
});
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
if (!apiKey)
|
|
107
|
+
die('API key is required');
|
|
108
|
+
saveConfig({
|
|
109
|
+
endpoint: opts.endpoint,
|
|
110
|
+
auth: apiKeyAuth(apiKey, opts.user),
|
|
111
|
+
});
|
|
112
|
+
console.log(`Configured: ${opts.endpoint}`);
|
|
113
|
+
});
|
|
114
|
+
const login = program.command('login').description('Manage saved credentials');
|
|
115
|
+
login
|
|
116
|
+
.command('api-key')
|
|
117
|
+
.description('Store an API key')
|
|
118
|
+
.requiredOption('-k, --key <apiKey>', 'API key')
|
|
119
|
+
.option('-u, --user <userId>', 'User ID')
|
|
120
|
+
.action((opts) => {
|
|
121
|
+
const config = peekConfig();
|
|
122
|
+
if (!config)
|
|
123
|
+
die("Run 'os1 init' first to set the endpoint.");
|
|
124
|
+
const defaultUserId = config.auth.type === 'apiKey' ? config.auth.userId : undefined;
|
|
125
|
+
saveConfig({
|
|
126
|
+
endpoint: config.endpoint,
|
|
127
|
+
auth: apiKeyAuth(opts.key, opts.user ?? defaultUserId),
|
|
128
|
+
});
|
|
129
|
+
console.log('API key saved.');
|
|
130
|
+
});
|
|
131
|
+
login
|
|
132
|
+
.command('device')
|
|
133
|
+
.description('Authorize via OAuth device flow')
|
|
134
|
+
.option('-e, --endpoint <url>', 'API endpoint')
|
|
135
|
+
.action(async (opts) => {
|
|
136
|
+
const config = peekConfig();
|
|
137
|
+
const endpoint = opts.endpoint ?? config?.endpoint ?? DEFAULT_ENDPOINT;
|
|
138
|
+
const device = await requestDeviceCode(endpoint);
|
|
139
|
+
console.log('Open this URL in your browser and enter the code:');
|
|
140
|
+
console.log(` ${device.verification_uri}`);
|
|
141
|
+
console.log(`Code: ${device.user_code}`);
|
|
142
|
+
console.log('Waiting for authorization...');
|
|
143
|
+
const token = await pollDeviceToken(endpoint, device.device_code, device.interval ?? 5);
|
|
144
|
+
saveConfig({ endpoint, auth: tokenAuth(token) });
|
|
145
|
+
console.log('Device authorization successful.');
|
|
146
|
+
});
|
|
147
|
+
program
|
|
148
|
+
.command('logout')
|
|
149
|
+
.description('Forget stored credentials')
|
|
150
|
+
.action(() => {
|
|
151
|
+
if (existsSync(CONFIG_FILE))
|
|
152
|
+
unlinkSync(CONFIG_FILE);
|
|
153
|
+
console.log('Credentials removed.');
|
|
154
|
+
});
|
|
155
|
+
program
|
|
156
|
+
.command('auth-test')
|
|
157
|
+
.description('Verify authentication')
|
|
158
|
+
.action(async () => {
|
|
159
|
+
const client = getClient();
|
|
160
|
+
const ok = await client.health();
|
|
161
|
+
console.log(ok ? 'OK' : 'FAILED — cannot reach API');
|
|
162
|
+
process.exit(ok ? 0 : 1);
|
|
163
|
+
});
|
|
164
|
+
const offices = program.command('offices').description('Office management');
|
|
165
|
+
offices.command('list').action(async () => {
|
|
166
|
+
json(await getClient().offices.list());
|
|
167
|
+
});
|
|
168
|
+
offices.command('create').requiredOption('-n, --name <name>', 'Name').action(async (opts) => {
|
|
169
|
+
json(await getClient().offices.create({ name: opts.name }));
|
|
170
|
+
});
|
|
171
|
+
offices.command('status <officeId>').action(async (id) => {
|
|
172
|
+
json(await getClient().offices.status(id));
|
|
173
|
+
});
|
|
174
|
+
offices.command('delete <officeId>').action(async (id) => {
|
|
175
|
+
await getClient().offices.delete(id);
|
|
176
|
+
console.log('Deleted');
|
|
177
|
+
});
|
|
178
|
+
const agents = program.command('agents').description('Agent management');
|
|
179
|
+
agents.command('list').requiredOption('-o, --office <id>', 'Office ID').action(async (opts) => {
|
|
180
|
+
json(await getClient().agents.list(opts.office));
|
|
181
|
+
});
|
|
182
|
+
agents
|
|
183
|
+
.command('hire')
|
|
184
|
+
.requiredOption('-o, --office <id>', 'Office ID')
|
|
185
|
+
.requiredOption('-n, --name <name>', 'Agent name')
|
|
186
|
+
.option('-r, --role <role>', 'Role')
|
|
187
|
+
.option('-m, --model <tier>', 'Model tier (opus/sonnet/haiku)')
|
|
188
|
+
.action(async (opts) => {
|
|
189
|
+
json(await getClient().agents.hire(opts.office, {
|
|
190
|
+
name: opts.name,
|
|
191
|
+
role: opts.role,
|
|
192
|
+
modelTier: opts.model,
|
|
193
|
+
}));
|
|
194
|
+
});
|
|
195
|
+
agents.command('get <officeId> <name>').action(async (officeId, name) => {
|
|
196
|
+
json(await getClient().agents.get(officeId, name));
|
|
197
|
+
});
|
|
198
|
+
agents.command('fire <officeId> <name>').action(async (officeId, name) => {
|
|
199
|
+
await getClient().agents.fire(officeId, name);
|
|
200
|
+
console.log(`Fired ${name}`);
|
|
201
|
+
});
|
|
202
|
+
agents
|
|
203
|
+
.command('logs <officeId> <name>')
|
|
204
|
+
.option('-t, --tail <n>', 'Lines', '100')
|
|
205
|
+
.action(async (officeId, name, opts) => {
|
|
206
|
+
const r = await getClient().agents.logs(officeId, name, { tail: parseInt(opts.tail, 10) });
|
|
207
|
+
console.log(r.logs);
|
|
208
|
+
});
|
|
209
|
+
agents
|
|
210
|
+
.command('activity <officeId> <name>')
|
|
211
|
+
.option('-l, --limit <n>', 'Limit', '20')
|
|
212
|
+
.action(async (officeId, name, opts) => {
|
|
213
|
+
json(await getClient().agents.activity(officeId, name, { limit: parseInt(opts.limit, 10) }));
|
|
214
|
+
});
|
|
215
|
+
const integ = program.command('integrations').description('Integration management');
|
|
216
|
+
integ.command('models').requiredOption('-o, --office <id>', 'Office ID').action(async (opts) => {
|
|
217
|
+
json(await getClient().integrations.listModels(opts.office));
|
|
218
|
+
});
|
|
219
|
+
program
|
|
220
|
+
.command('api <method> <path>')
|
|
221
|
+
.description('Raw authenticated API call')
|
|
222
|
+
.option('-d, --data <json>', 'Request body')
|
|
223
|
+
.action(async (method, path, opts) => {
|
|
224
|
+
const client = getClient();
|
|
225
|
+
const body = opts.data ? JSON.parse(opts.data) : undefined;
|
|
226
|
+
json(await client.transport.request(method.toUpperCase(), path, { body }));
|
|
227
|
+
});
|
|
228
|
+
program.parse();
|
|
229
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
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3B,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC3D,IAAI,CAAC,MAAM,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC;AAC7E,CAAC,CAAC,CAAC;AAEL,OAAO,CAAC,KAAK,EAAE,CAAC"}
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ClientConfig } from './types/index.js';
|
|
2
|
+
import { Transport } from './transport.js';
|
|
3
|
+
import { OfficesAPI } from './api/offices.js';
|
|
4
|
+
import { AgentsAPI } from './api/agents.js';
|
|
5
|
+
import { IntegrationsAPI } from './api/integrations.js';
|
|
6
|
+
/**
|
|
7
|
+
* OS-1 SDK client.
|
|
8
|
+
*
|
|
9
|
+
* @example
|
|
10
|
+
* ```typescript
|
|
11
|
+
* const client = new OS1Client({
|
|
12
|
+
* endpoint: 'https://api.mitosislabs.ai',
|
|
13
|
+
* apiKey: process.env.OS1_API_KEY,
|
|
14
|
+
* });
|
|
15
|
+
*
|
|
16
|
+
* const offices = await client.offices.list();
|
|
17
|
+
* const agents = await client.agents.list(offices[0].id);
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare class OS1Client {
|
|
21
|
+
readonly transport: Transport;
|
|
22
|
+
readonly offices: OfficesAPI;
|
|
23
|
+
readonly agents: AgentsAPI;
|
|
24
|
+
readonly integrations: IntegrationsAPI;
|
|
25
|
+
constructor(config: ClientConfig);
|
|
26
|
+
/** Health check — verify connectivity. */
|
|
27
|
+
health(): Promise<boolean>;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kBAAkB,CAAC;AACrD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;;;;;;;;;;;GAaG;AACH,qBAAa,SAAS;IACpB,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,OAAO,EAAE,UAAU,CAAC;IAC7B,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC3B,QAAQ,CAAC,YAAY,EAAE,eAAe,CAAC;gBAE3B,MAAM,EAAE,YAAY;IAOhC,0CAA0C;IACpC,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC;CAQjC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Transport } from './transport.js';
|
|
2
|
+
import { OfficesAPI } from './api/offices.js';
|
|
3
|
+
import { AgentsAPI } from './api/agents.js';
|
|
4
|
+
import { IntegrationsAPI } from './api/integrations.js';
|
|
5
|
+
/**
|
|
6
|
+
* OS-1 SDK client.
|
|
7
|
+
*
|
|
8
|
+
* @example
|
|
9
|
+
* ```typescript
|
|
10
|
+
* const client = new OS1Client({
|
|
11
|
+
* endpoint: 'https://api.mitosislabs.ai',
|
|
12
|
+
* apiKey: process.env.OS1_API_KEY,
|
|
13
|
+
* });
|
|
14
|
+
*
|
|
15
|
+
* const offices = await client.offices.list();
|
|
16
|
+
* const agents = await client.agents.list(offices[0].id);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
export class OS1Client {
|
|
20
|
+
transport;
|
|
21
|
+
offices;
|
|
22
|
+
agents;
|
|
23
|
+
integrations;
|
|
24
|
+
constructor(config) {
|
|
25
|
+
this.transport = new Transport(config);
|
|
26
|
+
this.offices = new OfficesAPI(this.transport);
|
|
27
|
+
this.agents = new AgentsAPI(this.transport);
|
|
28
|
+
this.integrations = new IntegrationsAPI(this.transport);
|
|
29
|
+
}
|
|
30
|
+
/** Health check — verify connectivity. */
|
|
31
|
+
async health() {
|
|
32
|
+
try {
|
|
33
|
+
const resp = await fetch(`${this.transport.endpoint}/healthz`);
|
|
34
|
+
return resp.ok;
|
|
35
|
+
}
|
|
36
|
+
catch {
|
|
37
|
+
return false;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD;;;;;;;;;;;;;GAaG;AACH,MAAM,OAAO,SAAS;IACX,SAAS,CAAY;IACrB,OAAO,CAAa;IACpB,MAAM,CAAY;IAClB,YAAY,CAAkB;IAEvC,YAAY,MAAoB;QAC9B,IAAI,CAAC,SAAS,GAAG,IAAI,SAAS,CAAC,MAAM,CAAC,CAAC;QACvC,IAAI,CAAC,OAAO,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC9C,IAAI,CAAC,MAAM,GAAG,IAAI,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;QAC5C,IAAI,CAAC,YAAY,GAAG,IAAI,eAAe,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC;IAC1D,CAAC;IAED,0CAA0C;IAC1C,KAAK,CAAC,MAAM;QACV,IAAI,CAAC;YACH,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,QAAQ,UAAU,CAAC,CAAC;YAC/D,OAAO,IAAI,CAAC,EAAE,CAAC;QACjB,CAAC;QAAC,MAAM,CAAC;YACP,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export { OS1Client } from './client.js';
|
|
2
|
+
export { OfficesAPI } from './api/offices.js';
|
|
3
|
+
export { AgentsAPI } from './api/agents.js';
|
|
4
|
+
export { IntegrationsAPI } from './api/integrations.js';
|
|
5
|
+
export type * from './types/index.js';
|
|
6
|
+
export { OS1Error } from './types/index.js';
|
|
7
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,mBAAmB,kBAAkB,CAAC;AACtC,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { OS1Client } from './client.js';
|
|
2
|
+
export { OfficesAPI } from './api/offices.js';
|
|
3
|
+
export { AgentsAPI } from './api/agents.js';
|
|
4
|
+
export { IntegrationsAPI } from './api/integrations.js';
|
|
5
|
+
export { OS1Error } from './types/index.js';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAC9C,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAExD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { ClientConfig } from './types/index.js';
|
|
2
|
+
export declare class Transport {
|
|
3
|
+
private config;
|
|
4
|
+
constructor(config: ClientConfig);
|
|
5
|
+
private authHeaders;
|
|
6
|
+
request<T>(method: string, path: string, options?: {
|
|
7
|
+
body?: unknown;
|
|
8
|
+
query?: Record<string, string | number | undefined>;
|
|
9
|
+
raw?: boolean;
|
|
10
|
+
}): Promise<T>;
|
|
11
|
+
get<T>(path: string, query?: Record<string, string | number | undefined>): Promise<T>;
|
|
12
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
13
|
+
put<T>(path: string, body?: unknown): Promise<T>;
|
|
14
|
+
patch<T>(path: string, body?: unknown): Promise<T>;
|
|
15
|
+
delete<T>(path: string): Promise<T>;
|
|
16
|
+
get endpoint(): string;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=transport.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.d.ts","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAc,YAAY,EAAE,MAAM,kBAAkB,CAAC;AAIjE,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAe;gBAEjB,MAAM,EAAE,YAAY;YAIlB,WAAW;IAWnB,OAAO,CAAC,CAAC,EACb,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE;QACR,IAAI,CAAC,EAAE,OAAO,CAAC;QACf,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC;QACpD,GAAG,CAAC,EAAE,OAAO,CAAC;KACf,GACA,OAAO,CAAC,CAAC,CAAC;IAqDb,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IAIrF,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAIjD,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAIhD,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAIlD,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAInC,IAAI,QAAQ,IAAI,MAAM,CAErB;CACF"}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { makeAuthHeader } from './auth/index.js';
|
|
2
|
+
import { OS1Error } from './types/index.js';
|
|
3
|
+
export class Transport {
|
|
4
|
+
config;
|
|
5
|
+
constructor(config) {
|
|
6
|
+
this.config = config;
|
|
7
|
+
}
|
|
8
|
+
async authHeaders() {
|
|
9
|
+
const auth = this.config.auth;
|
|
10
|
+
if (auth.type === 'apiKey') {
|
|
11
|
+
return { Authorization: makeAuthHeader(auth.key, auth.userId) };
|
|
12
|
+
}
|
|
13
|
+
if (auth.type === 'token') {
|
|
14
|
+
return { Authorization: `Bearer ${auth.token}` };
|
|
15
|
+
}
|
|
16
|
+
throw new Error('Unsupported auth configuration');
|
|
17
|
+
}
|
|
18
|
+
async request(method, path, options) {
|
|
19
|
+
let fullPath = path;
|
|
20
|
+
if (options?.query) {
|
|
21
|
+
const params = new URLSearchParams();
|
|
22
|
+
for (const [k, v] of Object.entries(options.query)) {
|
|
23
|
+
if (v !== undefined)
|
|
24
|
+
params.set(k, String(v));
|
|
25
|
+
}
|
|
26
|
+
const qs = params.toString();
|
|
27
|
+
if (qs)
|
|
28
|
+
fullPath += `?${qs}`;
|
|
29
|
+
}
|
|
30
|
+
const url = `${this.config.endpoint}${fullPath}`;
|
|
31
|
+
const headers = { ...(await this.authHeaders()) };
|
|
32
|
+
if (options?.body && !(options.body instanceof FormData)) {
|
|
33
|
+
headers['Content-Type'] = 'application/json';
|
|
34
|
+
}
|
|
35
|
+
const controller = new AbortController();
|
|
36
|
+
const timeout = this.config.timeout ?? 30000;
|
|
37
|
+
const timer = setTimeout(() => controller.abort(), timeout);
|
|
38
|
+
try {
|
|
39
|
+
const response = await fetch(url, {
|
|
40
|
+
method,
|
|
41
|
+
headers,
|
|
42
|
+
body: options?.body
|
|
43
|
+
? options.body instanceof FormData ? options.body : JSON.stringify(options.body)
|
|
44
|
+
: undefined,
|
|
45
|
+
signal: controller.signal,
|
|
46
|
+
});
|
|
47
|
+
if (!response.ok) {
|
|
48
|
+
let message = response.statusText;
|
|
49
|
+
let code;
|
|
50
|
+
try {
|
|
51
|
+
const err = await response.json();
|
|
52
|
+
message = err.message ?? err.error ?? message;
|
|
53
|
+
code = err.code;
|
|
54
|
+
}
|
|
55
|
+
catch { }
|
|
56
|
+
throw new OS1Error(response.status, message, code);
|
|
57
|
+
}
|
|
58
|
+
if (options?.raw)
|
|
59
|
+
return response;
|
|
60
|
+
const contentType = response.headers.get('content-type') ?? '';
|
|
61
|
+
if (contentType.includes('application/json'))
|
|
62
|
+
return (await response.json());
|
|
63
|
+
return (await response.text());
|
|
64
|
+
}
|
|
65
|
+
finally {
|
|
66
|
+
clearTimeout(timer);
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
get(path, query) {
|
|
70
|
+
return this.request('GET', path, { query });
|
|
71
|
+
}
|
|
72
|
+
post(path, body) {
|
|
73
|
+
return this.request('POST', path, { body });
|
|
74
|
+
}
|
|
75
|
+
put(path, body) {
|
|
76
|
+
return this.request('PUT', path, { body });
|
|
77
|
+
}
|
|
78
|
+
patch(path, body) {
|
|
79
|
+
return this.request('PATCH', path, { body });
|
|
80
|
+
}
|
|
81
|
+
delete(path) {
|
|
82
|
+
return this.request('DELETE', path);
|
|
83
|
+
}
|
|
84
|
+
get endpoint() {
|
|
85
|
+
return this.config.endpoint;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"transport.js","sourceRoot":"","sources":["../src/transport.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAE5C,MAAM,OAAO,SAAS;IACZ,MAAM,CAAe;IAE7B,YAAY,MAAoB;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEO,KAAK,CAAC,WAAW;QACvB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC;QAC9B,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ,EAAE,CAAC;YAC3B,OAAO,EAAE,aAAa,EAAE,cAAc,CAAC,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC;QAClE,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,KAAK,OAAO,EAAE,CAAC;YAC1B,OAAO,EAAE,aAAa,EAAE,UAAU,IAAI,CAAC,KAAK,EAAE,EAAE,CAAC;QACnD,CAAC;QACD,MAAM,IAAI,KAAK,CAAC,gCAAgC,CAAC,CAAC;IACpD,CAAC;IAED,KAAK,CAAC,OAAO,CACX,MAAc,EACd,IAAY,EACZ,OAIC;QAED,IAAI,Q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IAAc;QAClC,OAAO,IAAI,CAAC,OAAO,CAAI,MAAM,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IACjD,CAAC;IAED,GAAG,CAAI,IAAY,EAAE,IAAc;QACjC,OAAO,IAAI,CAAC,OAAO,CAAI,KAAK,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAChD,CAAC;IAED,KAAK,CAAI,IAAY,EAAE,IAAc;QACnC,OAAO,IAAI,CAAC,OAAO,CAAI,OAAO,EAAE,IAAI,EAAE,EAAE,IAAI,EAAE,CAAC,CAAC;IAClD,CAAC;IAED,MAAM,CAAI,IAAY;QACpB,OAAO,IAAI,CAAC,OAAO,CAAI,QAAQ,EAAE,IAAI,CAAC,CAAC;IACzC,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC;IAC9B,CAAC;CACF"}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
export interface ClientConfig {
|
|
2
|
+
/** OS-1 API endpoint */
|
|
3
|
+
endpoint: string;
|
|
4
|
+
/** Authentication configuration */
|
|
5
|
+
auth: AuthConfig;
|
|
6
|
+
/** Request timeout in ms (default: 30000) */
|
|
7
|
+
timeout?: number;
|
|
8
|
+
}
|
|
9
|
+
export type AuthConfig = ApiKeyAuth | TokenAuth;
|
|
10
|
+
export interface ApiKeyAuth {
|
|
11
|
+
type: 'apiKey';
|
|
12
|
+
key: string;
|
|
13
|
+
userId?: string;
|
|
14
|
+
}
|
|
15
|
+
export interface TokenAuth {
|
|
16
|
+
type: 'token';
|
|
17
|
+
token: string;
|
|
18
|
+
}
|
|
19
|
+
export interface Office {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
owner_id: string;
|
|
23
|
+
created_at: string;
|
|
24
|
+
settings?: Record<string, unknown>;
|
|
25
|
+
}
|
|
26
|
+
export interface CreateOfficeRequest {
|
|
27
|
+
name: string;
|
|
28
|
+
}
|
|
29
|
+
export interface OfficeSettings {
|
|
30
|
+
[key: string]: unknown;
|
|
31
|
+
}
|
|
32
|
+
export interface ClusterStatus {
|
|
33
|
+
phase: string;
|
|
34
|
+
message?: string;
|
|
35
|
+
}
|
|
36
|
+
export interface Agent {
|
|
37
|
+
name: string;
|
|
38
|
+
role?: string;
|
|
39
|
+
modelTier?: string;
|
|
40
|
+
modelProvider?: string;
|
|
41
|
+
skills?: string[];
|
|
42
|
+
status?: AgentStatus;
|
|
43
|
+
}
|
|
44
|
+
export interface AgentStatus {
|
|
45
|
+
phase?: string;
|
|
46
|
+
ready?: boolean;
|
|
47
|
+
message?: string;
|
|
48
|
+
}
|
|
49
|
+
export interface HireAgentRequest {
|
|
50
|
+
name: string;
|
|
51
|
+
role?: string;
|
|
52
|
+
modelTier?: string;
|
|
53
|
+
skills?: string[];
|
|
54
|
+
env?: Record<string, string>;
|
|
55
|
+
}
|
|
56
|
+
export interface UpdateAgentRequest {
|
|
57
|
+
role?: string;
|
|
58
|
+
modelTier?: string;
|
|
59
|
+
skills?: string[];
|
|
60
|
+
env?: Record<string, string>;
|
|
61
|
+
}
|
|
62
|
+
export interface PromoteRequest {
|
|
63
|
+
modelTier: string;
|
|
64
|
+
provider?: string;
|
|
65
|
+
}
|
|
66
|
+
export interface SkillsRequest {
|
|
67
|
+
add?: string[];
|
|
68
|
+
remove?: string[];
|
|
69
|
+
}
|
|
70
|
+
export interface AgentLogs {
|
|
71
|
+
logs: string;
|
|
72
|
+
pod: string;
|
|
73
|
+
}
|
|
74
|
+
export interface ActivityEvent {
|
|
75
|
+
id: string;
|
|
76
|
+
category: string;
|
|
77
|
+
type: string;
|
|
78
|
+
summary: string;
|
|
79
|
+
timestamp: string;
|
|
80
|
+
metadata?: Record<string, unknown>;
|
|
81
|
+
}
|
|
82
|
+
export interface ActivityQuery {
|
|
83
|
+
limit?: number;
|
|
84
|
+
offset?: number;
|
|
85
|
+
category?: string;
|
|
86
|
+
since?: string;
|
|
87
|
+
}
|
|
88
|
+
export interface ModelInfo {
|
|
89
|
+
provider: string;
|
|
90
|
+
model_id: string;
|
|
91
|
+
name: string;
|
|
92
|
+
available: boolean;
|
|
93
|
+
}
|
|
94
|
+
export interface IntegrationSecret {
|
|
95
|
+
provider: string;
|
|
96
|
+
has_key: boolean;
|
|
97
|
+
updated_at?: string;
|
|
98
|
+
}
|
|
99
|
+
export declare class OS1Error extends Error {
|
|
100
|
+
status: number;
|
|
101
|
+
code?: string;
|
|
102
|
+
constructor(status: number, message: string, code?: string);
|
|
103
|
+
}
|
|
104
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,YAAY;IAC3B,wBAAwB;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,mCAAmC;IACnC,IAAI,EAAE,UAAU,CAAC;IACjB,6CAA6C;IAC7C,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,UAAU,GAAG,UAAU,GAAG,SAAS,CAAC;AAEhD,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,QAAQ,CAAC;IACf,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,OAAO,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf;AAID,MAAM,WAAW,MAAM;IACrB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,mBAAmB;IAClC,IAAI,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,cAAc;IAC7B,CAAC,GAAG,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,GAAG,EAAE,MAAM,CAAC;CACb;AAID,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAID,MAAM,WAAW,SAAS;IACxB,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,OAAO,CAAC;CACpB;AAED,MAAM,WAAW,iBAAiB;IAChC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAID,qBAAa,QAAS,SAAQ,KAAK;IACjC,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;gBAEF,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,MAAM;CAM3D"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
// ─── Auth ────────────────────────────────────────────────────────────────────
|
|
2
|
+
// ─── Errors ──────────────────────────────────────────────────────────────────
|
|
3
|
+
export class OS1Error extends Error {
|
|
4
|
+
status;
|
|
5
|
+
code;
|
|
6
|
+
constructor(status, message, code) {
|
|
7
|
+
super(message);
|
|
8
|
+
this.name = 'OS1Error';
|
|
9
|
+
this.status = status;
|
|
10
|
+
this.code = code;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,gFAAgF;AA+HhF,gFAAgF;AAEhF,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjC,MAAM,CAAS;IACf,IAAI,CAAU;IAEd,YAAY,MAAc,EAAE,OAAe,EAAE,IAAa;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,UAAU,CAAC;QACvB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mitosislabs/sdk",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "TypeScript SDK for managing OS-1 offices, agents, and integrations",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"os1": "dist/cli/index.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"dev": "tsc --watch",
|
|
13
|
+
"test": "vitest run",
|
|
14
|
+
"test:watch": "vitest",
|
|
15
|
+
"lint": "tsc --noEmit",
|
|
16
|
+
"clean": "rm -rf dist",
|
|
17
|
+
"prepublishOnly": "npm run clean && npm run build"
|
|
18
|
+
},
|
|
19
|
+
"files": [
|
|
20
|
+
"dist",
|
|
21
|
+
"README.md"
|
|
22
|
+
],
|
|
23
|
+
"keywords": ["os1", "sdk", "offices", "agents", "integrations"],
|
|
24
|
+
"type": "module",
|
|
25
|
+
"license": "MIT",
|
|
26
|
+
"engines": {
|
|
27
|
+
"node": ">=18"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"commander": "^12.1.0"
|
|
31
|
+
},
|
|
32
|
+
"devDependencies": {
|
|
33
|
+
"@types/node": "^20.14.0",
|
|
34
|
+
"typescript": "^5.5.0",
|
|
35
|
+
"vitest": "^2.0.0"
|
|
36
|
+
}
|
|
37
|
+
}
|