codai-sdk 0.3.1 → 0.4.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/dist/index.d.ts +7575 -4025
- package/dist/index.js +463 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -669,6 +669,256 @@ var Embeddings = class {
|
|
|
669
669
|
}
|
|
670
670
|
};
|
|
671
671
|
|
|
672
|
+
// src/resources/environments.ts
|
|
673
|
+
var envPath = (id, suffix = "") => `/v1/environments/${encodeURIComponent(id)}${suffix}`;
|
|
674
|
+
var EnvironmentMembers = class {
|
|
675
|
+
constructor(http) {
|
|
676
|
+
this.http = http;
|
|
677
|
+
}
|
|
678
|
+
http;
|
|
679
|
+
/** `GET /v1/environments/{id}/members` — any role. */
|
|
680
|
+
async list(envId, opts = {}) {
|
|
681
|
+
const raw = await this.http.json(envPath(envId, "/members"), {
|
|
682
|
+
ext: opts.ext,
|
|
683
|
+
signal: opts.signal
|
|
684
|
+
});
|
|
685
|
+
return [...raw.members ?? []];
|
|
686
|
+
}
|
|
687
|
+
/** `POST /v1/environments/{id}/members` — exactly one of `user_id` / `email`. */
|
|
688
|
+
async add(envId, body, opts = {}) {
|
|
689
|
+
const raw = await this.http.json(
|
|
690
|
+
envPath(envId, "/members"),
|
|
691
|
+
{ body, ext: opts.ext, signal: opts.signal }
|
|
692
|
+
);
|
|
693
|
+
return raw.member;
|
|
694
|
+
}
|
|
695
|
+
/** `PUT /v1/environments/{id}/members/me/ssh-key` — one `authorized_keys` line. */
|
|
696
|
+
setSshKey(envId, publicKey, opts = {}) {
|
|
697
|
+
const body = { public_key: publicKey };
|
|
698
|
+
return this.http.json(envPath(envId, "/members/me/ssh-key"), {
|
|
699
|
+
method: "PUT",
|
|
700
|
+
body,
|
|
701
|
+
ext: opts.ext,
|
|
702
|
+
signal: opts.signal
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
/** `PATCH /v1/environments/{id}/members/{userId}` — 409 `last_owner` on demoting the last owner. */
|
|
706
|
+
async setRole(envId, userId, role, opts = {}) {
|
|
707
|
+
const raw = await this.http.json(
|
|
708
|
+
envPath(envId, `/members/${encodeURIComponent(userId)}`),
|
|
709
|
+
{ method: "PATCH", body: { role }, ext: opts.ext, signal: opts.signal }
|
|
710
|
+
);
|
|
711
|
+
return raw.member;
|
|
712
|
+
}
|
|
713
|
+
/** `DELETE /v1/environments/{id}/members/{userId}` — pass your own id to leave. */
|
|
714
|
+
remove(envId, userId, opts = {}) {
|
|
715
|
+
return this.http.json(
|
|
716
|
+
envPath(envId, `/members/${encodeURIComponent(userId)}`),
|
|
717
|
+
{ method: "DELETE", ext: opts.ext, signal: opts.signal }
|
|
718
|
+
);
|
|
719
|
+
}
|
|
720
|
+
/** `POST /v1/environments/{id}/members/me/ssh-cert` — 12 h OpenSSH user certificate for your key. */
|
|
721
|
+
sshCert(envId, body, opts = {}) {
|
|
722
|
+
return this.http.json(envPath(envId, "/members/me/ssh-cert"), {
|
|
723
|
+
method: "POST",
|
|
724
|
+
body,
|
|
725
|
+
ext: opts.ext,
|
|
726
|
+
signal: opts.signal,
|
|
727
|
+
noRetry: true
|
|
728
|
+
});
|
|
729
|
+
}
|
|
730
|
+
};
|
|
731
|
+
var EnvironmentTasks = class {
|
|
732
|
+
constructor(http) {
|
|
733
|
+
this.http = http;
|
|
734
|
+
}
|
|
735
|
+
http;
|
|
736
|
+
/** `GET /v1/environments/{id}/tasks` */
|
|
737
|
+
list(envId, opts = {}) {
|
|
738
|
+
return this.http.json(envPath(envId, "/tasks"), { ext: opts.ext, signal: opts.signal });
|
|
739
|
+
}
|
|
740
|
+
/** `POST /v1/environments/{id}/tasks` — queued; you get a notification when it finishes. */
|
|
741
|
+
create(envId, body, opts = {}) {
|
|
742
|
+
return this.http.json(envPath(envId, "/tasks"), {
|
|
743
|
+
method: "POST",
|
|
744
|
+
body,
|
|
745
|
+
ext: opts.ext,
|
|
746
|
+
signal: opts.signal,
|
|
747
|
+
noRetry: true
|
|
748
|
+
});
|
|
749
|
+
}
|
|
750
|
+
/** `GET /v1/environments/{id}/tasks/{taskId}` */
|
|
751
|
+
get(envId, taskId, opts = {}) {
|
|
752
|
+
return this.http.json(envPath(envId, `/tasks/${encodeURIComponent(taskId)}`), { ext: opts.ext, signal: opts.signal });
|
|
753
|
+
}
|
|
754
|
+
};
|
|
755
|
+
var EnvironmentPorts = class {
|
|
756
|
+
constructor(http) {
|
|
757
|
+
this.http = http;
|
|
758
|
+
}
|
|
759
|
+
http;
|
|
760
|
+
/** `GET /v1/environments/{id}/ports` — published (forwarded) ports. */
|
|
761
|
+
async list(envId, opts = {}) {
|
|
762
|
+
const raw = await this.http.json(envPath(envId, "/ports"), {
|
|
763
|
+
ext: opts.ext,
|
|
764
|
+
signal: opts.signal
|
|
765
|
+
});
|
|
766
|
+
return [...raw.ports ?? []];
|
|
767
|
+
}
|
|
768
|
+
/** `PUT /v1/environments/{id}/ports/{port}` — publish or change visibility (upsert). */
|
|
769
|
+
async set(envId, port, body, opts = {}) {
|
|
770
|
+
const raw = await this.http.json(
|
|
771
|
+
envPath(envId, `/ports/${encodeURIComponent(String(port))}`),
|
|
772
|
+
{ method: "PUT", body, ext: opts.ext, signal: opts.signal }
|
|
773
|
+
);
|
|
774
|
+
return raw.port;
|
|
775
|
+
}
|
|
776
|
+
/** `DELETE /v1/environments/{id}/ports/{port}` — unpublish. */
|
|
777
|
+
remove(envId, port, opts = {}) {
|
|
778
|
+
return this.http.json(
|
|
779
|
+
envPath(envId, `/ports/${encodeURIComponent(String(port))}`),
|
|
780
|
+
{ method: "DELETE", ext: opts.ext, signal: opts.signal }
|
|
781
|
+
);
|
|
782
|
+
}
|
|
783
|
+
};
|
|
784
|
+
var EnvironmentSecrets = class {
|
|
785
|
+
constructor(http) {
|
|
786
|
+
this.http = http;
|
|
787
|
+
}
|
|
788
|
+
http;
|
|
789
|
+
/** `GET /v1/environments/{id}/secrets` — names and timestamps only, never values. */
|
|
790
|
+
async list(envId, opts = {}) {
|
|
791
|
+
const raw = await this.http.json(envPath(envId, "/secrets"), {
|
|
792
|
+
ext: opts.ext,
|
|
793
|
+
signal: opts.signal
|
|
794
|
+
});
|
|
795
|
+
return [...raw.secrets ?? []];
|
|
796
|
+
}
|
|
797
|
+
/** `PUT /v1/environments/{id}/secrets/{name}` — upsert; `name` is `ENV_STYLE`. */
|
|
798
|
+
set(envId, name, value, opts = {}) {
|
|
799
|
+
const body = { value };
|
|
800
|
+
return this.http.json(
|
|
801
|
+
envPath(envId, `/secrets/${encodeURIComponent(name)}`),
|
|
802
|
+
{ method: "PUT", body, ext: opts.ext, signal: opts.signal }
|
|
803
|
+
);
|
|
804
|
+
}
|
|
805
|
+
/** `DELETE /v1/environments/{id}/secrets/{name}` */
|
|
806
|
+
remove(envId, name, opts = {}) {
|
|
807
|
+
return this.http.json(
|
|
808
|
+
envPath(envId, `/secrets/${encodeURIComponent(name)}`),
|
|
809
|
+
{ method: "DELETE", ext: opts.ext, signal: opts.signal }
|
|
810
|
+
);
|
|
811
|
+
}
|
|
812
|
+
};
|
|
813
|
+
var Environments = class {
|
|
814
|
+
constructor(http) {
|
|
815
|
+
this.http = http;
|
|
816
|
+
this.members = new EnvironmentMembers(http);
|
|
817
|
+
this.ports = new EnvironmentPorts(http);
|
|
818
|
+
this.secrets = new EnvironmentSecrets(http);
|
|
819
|
+
this.tasks = new EnvironmentTasks(http);
|
|
820
|
+
}
|
|
821
|
+
http;
|
|
822
|
+
members;
|
|
823
|
+
ports;
|
|
824
|
+
secrets;
|
|
825
|
+
tasks;
|
|
826
|
+
/** `GET /v1/environments/{id}/ssh-ca` — CA public keys to trust (`@cert-authority` lines). */
|
|
827
|
+
sshCa(envId, opts = {}) {
|
|
828
|
+
return this.http.json(envPath(envId, "/ssh-ca"), { ext: opts.ext, signal: opts.signal });
|
|
829
|
+
}
|
|
830
|
+
/** `GET /v1/environments?project_id=&for_user_id=me` — newest first, every state. */
|
|
831
|
+
async list(query = {}, opts = {}) {
|
|
832
|
+
const raw = await this.http.json("/v1/environments", {
|
|
833
|
+
query: { project_id: query.project_id, for_user_id: query.for_user_id },
|
|
834
|
+
ext: opts.ext,
|
|
835
|
+
signal: opts.signal
|
|
836
|
+
});
|
|
837
|
+
return [...raw.environments ?? []];
|
|
838
|
+
}
|
|
839
|
+
/**
|
|
840
|
+
* `POST /v1/environments` — `byo` starts `pending`; managed providers start
|
|
841
|
+
* `creating`. 409 `already_has_env` in a `vm_per_dev` project (the error
|
|
842
|
+
* body carries the `environment_id` to reuse).
|
|
843
|
+
*/
|
|
844
|
+
async create(body, opts = {}) {
|
|
845
|
+
const raw = await this.http.json("/v1/environments", {
|
|
846
|
+
body,
|
|
847
|
+
ext: opts.ext,
|
|
848
|
+
signal: opts.signal,
|
|
849
|
+
noRetry: true
|
|
850
|
+
});
|
|
851
|
+
return raw.environment;
|
|
852
|
+
}
|
|
853
|
+
/**
|
|
854
|
+
* `POST /v1/environments/enroll` — daemon side. The one-time `codai_env_…`
|
|
855
|
+
* token in the body is the only credential; the client's API key header is
|
|
856
|
+
* ignored by this route. Managed environments additionally receive a
|
|
857
|
+
* freshly minted `api_key`, returned exactly once.
|
|
858
|
+
*/
|
|
859
|
+
enroll(body, opts = {}) {
|
|
860
|
+
return this.http.json("/v1/environments/enroll", {
|
|
861
|
+
body,
|
|
862
|
+
ext: opts.ext,
|
|
863
|
+
signal: opts.signal,
|
|
864
|
+
// The token is consumed on success; a retried POST would 401.
|
|
865
|
+
noRetry: true
|
|
866
|
+
});
|
|
867
|
+
}
|
|
868
|
+
/** `GET /v1/environments/{id}` — environment, your role, members, ports, recent events. */
|
|
869
|
+
get(envId, opts = {}) {
|
|
870
|
+
return this.http.json(envPath(envId), {
|
|
871
|
+
ext: opts.ext,
|
|
872
|
+
signal: opts.signal
|
|
873
|
+
});
|
|
874
|
+
}
|
|
875
|
+
/** `PATCH /v1/environments/{id}` — `name` and/or `idle_timeout_minutes` (5..1440). */
|
|
876
|
+
async update(envId, body, opts = {}) {
|
|
877
|
+
const raw = await this.http.json(envPath(envId), {
|
|
878
|
+
method: "PATCH",
|
|
879
|
+
body,
|
|
880
|
+
ext: opts.ext,
|
|
881
|
+
signal: opts.signal
|
|
882
|
+
});
|
|
883
|
+
return raw.environment;
|
|
884
|
+
}
|
|
885
|
+
/** `POST /v1/environments/{id}/start` — managed providers only (`stopped` → `starting`). */
|
|
886
|
+
start(envId, opts = {}) {
|
|
887
|
+
return this.transition(envId, "start", opts);
|
|
888
|
+
}
|
|
889
|
+
/** `POST /v1/environments/{id}/stop` — managed providers only (`running` → `stopping`). */
|
|
890
|
+
stop(envId, opts = {}) {
|
|
891
|
+
return this.transition(envId, "stop", opts);
|
|
892
|
+
}
|
|
893
|
+
/** `POST /v1/environments/{id}/archive` — keeps history, releases the machine. */
|
|
894
|
+
archive(envId, opts = {}) {
|
|
895
|
+
return this.transition(envId, "archive", opts);
|
|
896
|
+
}
|
|
897
|
+
/** `POST /v1/environments/{id}/destroy` — owner only; terminal. */
|
|
898
|
+
destroy(envId, opts = {}) {
|
|
899
|
+
return this.transition(envId, "destroy", opts);
|
|
900
|
+
}
|
|
901
|
+
/**
|
|
902
|
+
* `POST /v1/environments/{id}/enroll-token` — `byo` only; a 30-minute
|
|
903
|
+
* one-time token for `enroll()`. Minting again replaces the previous one.
|
|
904
|
+
*/
|
|
905
|
+
enrollToken(envId, opts = {}) {
|
|
906
|
+
return this.http.json(envPath(envId, "/enroll-token"), {
|
|
907
|
+
method: "POST",
|
|
908
|
+
ext: opts.ext,
|
|
909
|
+
signal: opts.signal,
|
|
910
|
+
noRetry: true
|
|
911
|
+
});
|
|
912
|
+
}
|
|
913
|
+
transition(envId, action, opts) {
|
|
914
|
+
return this.http.json(envPath(envId, `/${action}`), {
|
|
915
|
+
method: "POST",
|
|
916
|
+
ext: opts.ext,
|
|
917
|
+
signal: opts.signal
|
|
918
|
+
});
|
|
919
|
+
}
|
|
920
|
+
};
|
|
921
|
+
|
|
672
922
|
// src/resources/health.ts
|
|
673
923
|
var Health = class {
|
|
674
924
|
constructor(http) {
|
|
@@ -921,6 +1171,54 @@ var Orgs = class {
|
|
|
921
1171
|
}
|
|
922
1172
|
};
|
|
923
1173
|
|
|
1174
|
+
// src/resources/projects.ts
|
|
1175
|
+
var Projects = class {
|
|
1176
|
+
constructor(http) {
|
|
1177
|
+
this.http = http;
|
|
1178
|
+
}
|
|
1179
|
+
http;
|
|
1180
|
+
/** `GET /v1/projects` — projects you own plus those of your orgs, newest first. */
|
|
1181
|
+
async list(opts = {}) {
|
|
1182
|
+
const raw = await this.http.json("/v1/projects", {
|
|
1183
|
+
ext: opts.ext,
|
|
1184
|
+
signal: opts.signal
|
|
1185
|
+
});
|
|
1186
|
+
return [...raw.projects ?? []];
|
|
1187
|
+
}
|
|
1188
|
+
/** `POST /v1/projects` — 409 `slug_taken` when the slug is already yours. */
|
|
1189
|
+
async create(body, opts = {}) {
|
|
1190
|
+
const raw = await this.http.json("/v1/projects", {
|
|
1191
|
+
body,
|
|
1192
|
+
ext: opts.ext,
|
|
1193
|
+
signal: opts.signal
|
|
1194
|
+
});
|
|
1195
|
+
return raw.project;
|
|
1196
|
+
}
|
|
1197
|
+
/** `GET /v1/projects/{id}` — the project plus every environment in it. */
|
|
1198
|
+
get(projectId, opts = {}) {
|
|
1199
|
+
return this.http.json(`/v1/projects/${encodeURIComponent(projectId)}`, {
|
|
1200
|
+
ext: opts.ext,
|
|
1201
|
+
signal: opts.signal
|
|
1202
|
+
});
|
|
1203
|
+
}
|
|
1204
|
+
/** `PATCH /v1/projects/{id}` — owner or org owner/admin; the slug cannot change. */
|
|
1205
|
+
async update(projectId, body, opts = {}) {
|
|
1206
|
+
const raw = await this.http.json(
|
|
1207
|
+
`/v1/projects/${encodeURIComponent(projectId)}`,
|
|
1208
|
+
{ method: "PATCH", body, ext: opts.ext, signal: opts.signal }
|
|
1209
|
+
);
|
|
1210
|
+
return raw.project;
|
|
1211
|
+
}
|
|
1212
|
+
/** `DELETE /v1/projects/{id}` — 409 `project_has_environments` until all are destroyed. */
|
|
1213
|
+
delete(projectId, opts = {}) {
|
|
1214
|
+
return this.http.json(`/v1/projects/${encodeURIComponent(projectId)}`, {
|
|
1215
|
+
method: "DELETE",
|
|
1216
|
+
ext: opts.ext,
|
|
1217
|
+
signal: opts.signal
|
|
1218
|
+
});
|
|
1219
|
+
}
|
|
1220
|
+
};
|
|
1221
|
+
|
|
924
1222
|
// src/resources/responses.ts
|
|
925
1223
|
var Responses = class {
|
|
926
1224
|
constructor(http) {
|
|
@@ -1215,6 +1513,26 @@ var Sessions = class {
|
|
|
1215
1513
|
}
|
|
1216
1514
|
};
|
|
1217
1515
|
|
|
1516
|
+
// src/resources/system-one.ts
|
|
1517
|
+
var SystemOne = class {
|
|
1518
|
+
constructor(http) {
|
|
1519
|
+
this.http = http;
|
|
1520
|
+
}
|
|
1521
|
+
http;
|
|
1522
|
+
/**
|
|
1523
|
+
* Ask one or more typed questions about `state`. Throws on 503 `s1_unavailable` like any other
|
|
1524
|
+
* error — keep a local fallback and catch it: the gateway never substitutes a generative model.
|
|
1525
|
+
*/
|
|
1526
|
+
async create(body, opts = {}) {
|
|
1527
|
+
const res = await this.http.request("/v1/systemone", {
|
|
1528
|
+
body,
|
|
1529
|
+
ext: opts.ext,
|
|
1530
|
+
signal: opts.signal
|
|
1531
|
+
});
|
|
1532
|
+
return await res.json();
|
|
1533
|
+
}
|
|
1534
|
+
};
|
|
1535
|
+
|
|
1218
1536
|
// src/resources/tasks.ts
|
|
1219
1537
|
var Tasks = class {
|
|
1220
1538
|
constructor(http) {
|
|
@@ -1262,6 +1580,91 @@ var Tasks = class {
|
|
|
1262
1580
|
}
|
|
1263
1581
|
};
|
|
1264
1582
|
|
|
1583
|
+
// src/resources/triggers.ts
|
|
1584
|
+
var Triggers = class {
|
|
1585
|
+
constructor(http) {
|
|
1586
|
+
this.http = http;
|
|
1587
|
+
}
|
|
1588
|
+
http;
|
|
1589
|
+
/** `GET /v1/triggers` — never includes the signing secret. */
|
|
1590
|
+
list(opts = {}) {
|
|
1591
|
+
return this.http.json("/v1/triggers", { ext: opts.ext, signal: opts.signal });
|
|
1592
|
+
}
|
|
1593
|
+
/** `POST /v1/triggers` — the response carries the signing `secret` ONCE. */
|
|
1594
|
+
create(body, opts = {}) {
|
|
1595
|
+
return this.http.json("/v1/triggers", { method: "POST", body, ext: opts.ext, signal: opts.signal });
|
|
1596
|
+
}
|
|
1597
|
+
/** `PATCH /v1/triggers/{id}` — name / enabled / policy. */
|
|
1598
|
+
update(id, body, opts = {}) {
|
|
1599
|
+
return this.http.json(`/v1/triggers/${encodeURIComponent(id)}`, { method: "PATCH", body, ext: opts.ext, signal: opts.signal });
|
|
1600
|
+
}
|
|
1601
|
+
/** `DELETE /v1/triggers/{id}` — its hook URL stops working immediately. */
|
|
1602
|
+
delete(id, opts = {}) {
|
|
1603
|
+
return this.http.json(`/v1/triggers/${encodeURIComponent(id)}`, { method: "DELETE", ext: opts.ext, signal: opts.signal });
|
|
1604
|
+
}
|
|
1605
|
+
/** `POST /v1/triggers/{id}/rotate-secret` — new secret, shown once. */
|
|
1606
|
+
rotateSecret(id, opts = {}) {
|
|
1607
|
+
return this.http.json(`/v1/triggers/${encodeURIComponent(id)}/rotate-secret`, { method: "POST", body: {}, ext: opts.ext, signal: opts.signal });
|
|
1608
|
+
}
|
|
1609
|
+
/** `POST /v1/triggers/{id}/test` — manual fire through the full pipeline; returns the decision + reason. */
|
|
1610
|
+
/** `PUT /v1/triggers/{id}/secret` — store a secret issued by the source (e.g. a Sentry integration's client secret). */
|
|
1611
|
+
setSecret(id, secret, opts = {}) {
|
|
1612
|
+
return this.http.json(`/v1/triggers/${encodeURIComponent(id)}/secret`, { method: "PUT", body: { secret }, ext: opts.ext, signal: opts.signal, noRetry: true });
|
|
1613
|
+
}
|
|
1614
|
+
/** `POST /v1/triggers/{id}/test` — manual fire through the full pipeline; returns the decision + reason. */
|
|
1615
|
+
test(id, body = {}, opts = {}) {
|
|
1616
|
+
return this.http.json(`/v1/triggers/${encodeURIComponent(id)}/test`, { method: "POST", body, ext: opts.ext, signal: opts.signal });
|
|
1617
|
+
}
|
|
1618
|
+
/** `GET /v1/triggers/{id}/events?limit=` — recent deliveries with decisions. */
|
|
1619
|
+
events(id, limit, opts = {}) {
|
|
1620
|
+
return this.http.json(`/v1/triggers/${encodeURIComponent(id)}/events`, { query: { limit }, ext: opts.ext, signal: opts.signal });
|
|
1621
|
+
}
|
|
1622
|
+
/**
|
|
1623
|
+
* `POST /v1/hooks/{id}` — send an event to a `generic` / `form` trigger from your own code. Signs the body
|
|
1624
|
+
* (`X-Codai-Signature: t=<unix>,v1=HMAC_SHA256(secret, "<t>.<body>")`, WebCrypto — Node 20+, browsers, Deno,
|
|
1625
|
+
* Workers). `deliveryId` makes retries idempotent. The hook needs no API key (the signature is the auth).
|
|
1626
|
+
*/
|
|
1627
|
+
async fireHook(id, secret, event, opts = {}) {
|
|
1628
|
+
const raw = JSON.stringify(event);
|
|
1629
|
+
const t = Math.floor(Date.now() / 1e3);
|
|
1630
|
+
const key = await crypto.subtle.importKey("raw", new TextEncoder().encode(secret), { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
1631
|
+
const mac = new Uint8Array(await crypto.subtle.sign("HMAC", key, new TextEncoder().encode(`${t}.${raw}`)));
|
|
1632
|
+
const v1 = Array.from(mac, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
1633
|
+
return this.http.json(`/v1/hooks/${encodeURIComponent(id)}`, {
|
|
1634
|
+
method: "POST",
|
|
1635
|
+
rawBody: raw,
|
|
1636
|
+
ext: {
|
|
1637
|
+
...opts.ext,
|
|
1638
|
+
headers: {
|
|
1639
|
+
...opts.ext?.headers,
|
|
1640
|
+
"Content-Type": "application/json",
|
|
1641
|
+
"x-codai-signature": `t=${t},v1=${v1}`,
|
|
1642
|
+
...opts.deliveryId ? { "x-codai-delivery": opts.deliveryId } : {}
|
|
1643
|
+
}
|
|
1644
|
+
},
|
|
1645
|
+
signal: opts.signal
|
|
1646
|
+
});
|
|
1647
|
+
}
|
|
1648
|
+
};
|
|
1649
|
+
var Notifications = class {
|
|
1650
|
+
constructor(http) {
|
|
1651
|
+
this.http = http;
|
|
1652
|
+
}
|
|
1653
|
+
http;
|
|
1654
|
+
/** `GET /v1/notifications?unread=1&limit=` — newest first. */
|
|
1655
|
+
list(query = {}, opts = {}) {
|
|
1656
|
+
return this.http.json("/v1/notifications", {
|
|
1657
|
+
query: { unread: query.unread ? "1" : void 0, limit: query.limit },
|
|
1658
|
+
ext: opts.ext,
|
|
1659
|
+
signal: opts.signal
|
|
1660
|
+
});
|
|
1661
|
+
}
|
|
1662
|
+
/** `POST /v1/notifications/read` — `ids` omitted = every unread one. */
|
|
1663
|
+
markRead(ids, opts = {}) {
|
|
1664
|
+
return this.http.json("/v1/notifications/read", { method: "POST", body: ids ? { ids } : {}, ext: opts.ext, signal: opts.signal });
|
|
1665
|
+
}
|
|
1666
|
+
};
|
|
1667
|
+
|
|
1265
1668
|
// src/resources/tokens.ts
|
|
1266
1669
|
var Tokens = class {
|
|
1267
1670
|
constructor(http) {
|
|
@@ -1314,6 +1717,7 @@ var OPERATION_METHODS = {
|
|
|
1314
1717
|
createMessage: "messages.create",
|
|
1315
1718
|
// Embeddings & Audio
|
|
1316
1719
|
createEmbeddings: "embeddings.create",
|
|
1720
|
+
createSystemOne: "systemOne.create",
|
|
1317
1721
|
createTranscription: "audio.transcribe",
|
|
1318
1722
|
createSpeech: "audio.speech",
|
|
1319
1723
|
createEphemeralToken: "tokens.create",
|
|
@@ -1340,6 +1744,18 @@ var OPERATION_METHODS = {
|
|
|
1340
1744
|
getTaskStats: "tasks.stats",
|
|
1341
1745
|
getTask: "tasks.get",
|
|
1342
1746
|
confirmTask: "tasks.confirm",
|
|
1747
|
+
// Event triggers + inbox
|
|
1748
|
+
listTriggers: "triggers.list",
|
|
1749
|
+
createTrigger: "triggers.create",
|
|
1750
|
+
updateTrigger: "triggers.update",
|
|
1751
|
+
deleteTrigger: "triggers.delete",
|
|
1752
|
+
rotateTriggerSecret: "triggers.rotateSecret",
|
|
1753
|
+
setTriggerSecret: "triggers.setSecret",
|
|
1754
|
+
testTrigger: "triggers.test",
|
|
1755
|
+
listTriggerEvents: "triggers.events",
|
|
1756
|
+
receiveTriggerHook: "triggers.fireHook",
|
|
1757
|
+
listNotifications: "notifications.list",
|
|
1758
|
+
markNotificationsRead: "notifications.markRead",
|
|
1343
1759
|
// Sessions
|
|
1344
1760
|
createSession: "sessions.create",
|
|
1345
1761
|
listSessions: "sessions.list",
|
|
@@ -1376,6 +1792,39 @@ var OPERATION_METHODS = {
|
|
|
1376
1792
|
listOrgMembers: "orgs.members.list",
|
|
1377
1793
|
addOrgMember: "orgs.members.add",
|
|
1378
1794
|
removeOrgMember: "orgs.members.remove",
|
|
1795
|
+
// Projects
|
|
1796
|
+
listProjects: "projects.list",
|
|
1797
|
+
createProject: "projects.create",
|
|
1798
|
+
getProject: "projects.get",
|
|
1799
|
+
updateProject: "projects.update",
|
|
1800
|
+
deleteProject: "projects.delete",
|
|
1801
|
+
// Environments
|
|
1802
|
+
listEnvironments: "environments.list",
|
|
1803
|
+
createEnvironment: "environments.create",
|
|
1804
|
+
enrollEnvironment: "environments.enroll",
|
|
1805
|
+
getEnvironment: "environments.get",
|
|
1806
|
+
updateEnvironment: "environments.update",
|
|
1807
|
+
startEnvironment: "environments.start",
|
|
1808
|
+
stopEnvironment: "environments.stop",
|
|
1809
|
+
archiveEnvironment: "environments.archive",
|
|
1810
|
+
destroyEnvironment: "environments.destroy",
|
|
1811
|
+
createEnvironmentEnrollToken: "environments.enrollToken",
|
|
1812
|
+
listEnvironmentMembers: "environments.members.list",
|
|
1813
|
+
addEnvironmentMember: "environments.members.add",
|
|
1814
|
+
setMyEnvironmentSshKey: "environments.members.setSshKey",
|
|
1815
|
+
setEnvironmentMemberRole: "environments.members.setRole",
|
|
1816
|
+
removeEnvironmentMember: "environments.members.remove",
|
|
1817
|
+
issueMyEnvironmentSshCert: "environments.members.sshCert",
|
|
1818
|
+
getEnvironmentSshCa: "environments.sshCa",
|
|
1819
|
+
listEnvironmentTasks: "environments.tasks.list",
|
|
1820
|
+
createEnvironmentTask: "environments.tasks.create",
|
|
1821
|
+
getEnvironmentTask: "environments.tasks.get",
|
|
1822
|
+
listEnvironmentPorts: "environments.ports.list",
|
|
1823
|
+
setEnvironmentPort: "environments.ports.set",
|
|
1824
|
+
removeEnvironmentPort: "environments.ports.remove",
|
|
1825
|
+
listEnvironmentSecrets: "environments.secrets.list",
|
|
1826
|
+
setEnvironmentSecret: "environments.secrets.set",
|
|
1827
|
+
removeEnvironmentSecret: "environments.secrets.remove",
|
|
1379
1828
|
// Account
|
|
1380
1829
|
getAccount: "account.get",
|
|
1381
1830
|
patchAccount: "account.update",
|
|
@@ -1398,16 +1847,24 @@ var Codai = class {
|
|
|
1398
1847
|
responses;
|
|
1399
1848
|
embeddings;
|
|
1400
1849
|
audio;
|
|
1850
|
+
/** Typed decisions from codai-s1 (`systemOne.create({ state, questions })`). */
|
|
1851
|
+
systemOne;
|
|
1401
1852
|
tokens;
|
|
1402
1853
|
models;
|
|
1403
1854
|
health;
|
|
1404
1855
|
agents;
|
|
1405
1856
|
tools;
|
|
1406
1857
|
tasks;
|
|
1858
|
+
/** Event triggers — webhooks that notify you or start agent sessions. */
|
|
1859
|
+
triggers;
|
|
1860
|
+
/** Inbox of trigger / cloud-task notifications. */
|
|
1861
|
+
notifications;
|
|
1407
1862
|
sessions;
|
|
1408
1863
|
devices;
|
|
1409
1864
|
hosts;
|
|
1410
1865
|
orgs;
|
|
1866
|
+
projects;
|
|
1867
|
+
environments;
|
|
1411
1868
|
account;
|
|
1412
1869
|
receipt;
|
|
1413
1870
|
feedback;
|
|
@@ -1433,15 +1890,20 @@ var Codai = class {
|
|
|
1433
1890
|
this.messages = new Messages(http);
|
|
1434
1891
|
this.responses = new Responses(http);
|
|
1435
1892
|
this.audio = new Audio(http);
|
|
1893
|
+
this.systemOne = new SystemOne(http);
|
|
1436
1894
|
this.tokens = new Tokens(http);
|
|
1437
1895
|
this.health = new Health(http);
|
|
1438
1896
|
this.agents = new Agents(http);
|
|
1439
1897
|
this.tools = new Tools(http);
|
|
1440
1898
|
this.tasks = new Tasks(http);
|
|
1899
|
+
this.triggers = new Triggers(http);
|
|
1900
|
+
this.notifications = new Notifications(http);
|
|
1441
1901
|
this.sessions = new Sessions(http);
|
|
1442
1902
|
this.devices = new Devices(http);
|
|
1443
1903
|
this.hosts = new Hosts(http);
|
|
1444
1904
|
this.orgs = new Orgs(http);
|
|
1905
|
+
this.projects = new Projects(http);
|
|
1906
|
+
this.environments = new Environments(http);
|
|
1445
1907
|
this.account = new Account(http);
|
|
1446
1908
|
this.receipt = new Receipts(http);
|
|
1447
1909
|
this.phoneModels = new PhoneModels(http);
|
|
@@ -1529,6 +1991,6 @@ function allKeys(obj) {
|
|
|
1529
1991
|
}
|
|
1530
1992
|
var index_default = Codai;
|
|
1531
1993
|
|
|
1532
|
-
export { Account, AgentRuns, Agents, Audio, Chat, ChatCompletions, Codai, CodaiError, Devices, Embeddings, Feedback, Health, Hosts, HttpClient, Messages, Models, OPERATION_METHODS, OrgMembers, Orgs, PhoneModels, Receipts, Responses, STREAMING_OPERATIONS, SessionControls, SessionEvents, SessionLease, SessionShares, Sessions, Tasks, Tokens, Tools, index_default as default, extensionHeaders, frameJson, mergeToolCall, readSse };
|
|
1994
|
+
export { Account, AgentRuns, Agents, Audio, Chat, ChatCompletions, Codai, CodaiError, Devices, Embeddings, EnvironmentMembers, EnvironmentPorts, EnvironmentSecrets, EnvironmentTasks, Environments, Feedback, Health, Hosts, HttpClient, Messages, Models, Notifications, OPERATION_METHODS, OrgMembers, Orgs, PhoneModels, Projects, Receipts, Responses, STREAMING_OPERATIONS, SessionControls, SessionEvents, SessionLease, SessionShares, Sessions, Tasks, Tokens, Tools, Triggers, index_default as default, extensionHeaders, frameJson, mergeToolCall, readSse };
|
|
1533
1995
|
//# sourceMappingURL=index.js.map
|
|
1534
1996
|
//# sourceMappingURL=index.js.map
|