ql-agent-sdk 1.4.0 → 1.4.1
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 +124 -12
- package/dist/index.cjs +133 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +494 -1
- package/dist/index.d.ts +494 -1
- package/dist/index.js +133 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -867,6 +867,118 @@ const uploaded = await ql.files.upload(new Blob([blob], { type: "video/mp4" }),
|
|
|
867
867
|
});
|
|
868
868
|
```
|
|
869
869
|
|
|
870
|
+
### Architecture (Approvals · Policies · Events · Subagents · Skills · Executions)
|
|
871
|
+
|
|
872
|
+
The platform enforces a policy engine over every protected action (agent tool calls, workflow
|
|
873
|
+
nodes, skill runs, subagent tools). Protected actions that are not fully autonomous produce an
|
|
874
|
+
**approval request**; approved actions execute exactly once. All of this is observable and
|
|
875
|
+
controllable through the namespaces below. List endpoints return *list-safe* views (no bound
|
|
876
|
+
payloads); detail endpoints include full records.
|
|
877
|
+
|
|
878
|
+
#### `ql.approvals.list(params?)` → `Promise<ApprovalsListResult>`
|
|
879
|
+
|
|
880
|
+
**Scope:** `approvals`
|
|
881
|
+
|
|
882
|
+
Lists approval requests, newest first. `params?: { status?: ApprovalStatus[], limit?, beforeCreatedAt?: string | Date }`
|
|
883
|
+
— statuses: `pending`, `approved`, `rejected`, `expired`, `consumed`.
|
|
884
|
+
|
|
885
|
+
#### `ql.approvals.get(approvalId)` → `Promise<ApprovalDetail>`
|
|
886
|
+
|
|
887
|
+
**Scope:** `approvals`
|
|
888
|
+
|
|
889
|
+
Full record including the bound action payload, evaluation (rule pack / rule / severity / reason),
|
|
890
|
+
evidence, and decision metadata.
|
|
891
|
+
|
|
892
|
+
#### `ql.approvals.decide(approvalId, input)` → `Promise<DecideApprovalResult>`
|
|
893
|
+
|
|
894
|
+
**Scope:** `approvals`
|
|
895
|
+
|
|
896
|
+
Records an authorized workspace member's decision. `input: { decision: "approve" | "reject", decidedBy, note?, evidence? }`.
|
|
897
|
+
A user cannot approve their own request (403). State errors (pending/expired/consumed/…) → 409; unknown id → 404.
|
|
898
|
+
|
|
899
|
+
#### `ql.approvals.execute(approvalId)` → `Promise<ExecuteApprovalResult>`
|
|
900
|
+
|
|
901
|
+
**Scope:** `approvals`
|
|
902
|
+
|
|
903
|
+
Executes the bound action of an approved approval, consuming it atomically (no replays).
|
|
904
|
+
Returns `{ ok, approvalId, action, status: "consumed", result?, error? }` — executor failures return
|
|
905
|
+
`ok: false` with the error while the approval is still consumed.
|
|
906
|
+
|
|
907
|
+
#### `ql.policies.get()` → `Promise<PoliciesResult>`
|
|
908
|
+
|
|
909
|
+
**Scope:** `policies`
|
|
910
|
+
|
|
911
|
+
Returns active rule packs with their rules, the documented roadmap client packs (registered but
|
|
912
|
+
inactive), and honest stats `{ total, active, roadmap, rulesTotal }`.
|
|
913
|
+
|
|
914
|
+
#### `ql.events.list(params?)` → `Promise<EventsPage>`
|
|
915
|
+
|
|
916
|
+
**Scope:** `events`
|
|
917
|
+
|
|
918
|
+
Paginated read of the hash-chained audit ledger, newest first. `params?: { limit?, beforeSeq?, types?: string[] }`.
|
|
919
|
+
Returns `{ items, hasMore, nextBeforeSeq?, total? }` — walk pages by passing `nextBeforeSeq` back as `beforeSeq`.
|
|
920
|
+
|
|
921
|
+
#### `ql.events.verify(params?)` → `Promise<VerifyChainResult>`
|
|
922
|
+
|
|
923
|
+
**Scope:** `events`
|
|
924
|
+
|
|
925
|
+
Recomputes every event hash and checks each `prevHash` link over the window `seq <= afterSeq`
|
|
926
|
+
(all events when omitted). Returns `{ valid, checkedCount, firstBadSeq?, reason? }`.
|
|
927
|
+
|
|
928
|
+
#### `ql.events.retention()` → `Promise<RetentionReport>`
|
|
929
|
+
|
|
930
|
+
**Scope:** `events`
|
|
931
|
+
|
|
932
|
+
Retention report: `{ retentionDays: 365, oldestEventAt?, eventsInsideRetentionWindow,
|
|
933
|
+
eventsOutsideRetentionWindow, autoDeletionEnabled: false, note }`. No automatic deletion runs.
|
|
934
|
+
|
|
935
|
+
#### `ql.subagents.list(agentId?)` → `Promise<SubagentsListResult>`
|
|
936
|
+
|
|
937
|
+
**Scope:** `subagents`
|
|
938
|
+
|
|
939
|
+
Specialist definitions owned by the eight catalog agents (optionally filtered by owner) plus honest
|
|
940
|
+
stats `{ total, enabled, disabled, withHttp, byAgent }`. 54 definitions ship; 4 permit `http_request`.
|
|
941
|
+
|
|
942
|
+
#### `ql.subagents.get(subagentId)` → `Promise<SubagentDefinition>`
|
|
943
|
+
|
|
944
|
+
**Scope:** `subagents`
|
|
945
|
+
|
|
946
|
+
One definition: permitted tools, I/O contracts, execution constraints, applicability notes.
|
|
947
|
+
|
|
948
|
+
#### `ql.skills.list(domain?)` → `Promise<SkillsListResult>`
|
|
949
|
+
|
|
950
|
+
**Scope:** `skills`
|
|
951
|
+
|
|
952
|
+
Skill definitions (no implementation functions) plus honest stats `{ total, readOnly, write, enabled, byDomain }`.
|
|
953
|
+
3 skills ship, all read-class and enabled.
|
|
954
|
+
|
|
955
|
+
#### `ql.skills.get(skillId)` → `Promise<SkillDefinition>`
|
|
956
|
+
|
|
957
|
+
**Scope:** `skills`
|
|
958
|
+
|
|
959
|
+
One definition: I/O contract, execution class, version, description.
|
|
960
|
+
|
|
961
|
+
#### `ql.skills.run(input)` → `Promise<SkillRunResult>`
|
|
962
|
+
|
|
963
|
+
**Scope:** `skills`
|
|
964
|
+
|
|
965
|
+
Runs a skill through validation → authorization → policy → audit → execution.
|
|
966
|
+
`input: { skillId, input: Record<string, unknown>, actorUserId, idempotencyKey? }`.
|
|
967
|
+
Unknown/disabled skills → 404; invalid or oversized input → 400.
|
|
968
|
+
|
|
969
|
+
#### `ql.executions.list(params?)` → `Promise<ExecutionsListResult>`
|
|
970
|
+
|
|
971
|
+
**Scope:** `executions`
|
|
972
|
+
|
|
973
|
+
Execution history (list-safe views). `params?: { agentId?, status?: ExecutionStatus[], limit?, beforeCreatedAt?: string | Date }`.
|
|
974
|
+
|
|
975
|
+
#### `ql.executions.get(executionId)` → `Promise<ExecutionDetail>`
|
|
976
|
+
|
|
977
|
+
**Scope:** `executions`
|
|
978
|
+
|
|
979
|
+
Full trace: ordered tool calls (seq, toolName, ok, durationMs, error, approvalId, ledgerSeq), token
|
|
980
|
+
usage, approval/ledger back-references, and direct child executions (subagent runs).
|
|
981
|
+
|
|
870
982
|
---
|
|
871
983
|
|
|
872
984
|
## Error Handling
|
|
@@ -1037,18 +1149,18 @@ export async function POST(req: Request) {
|
|
|
1037
1149
|
|
|
1038
1150
|
## Agent Reference
|
|
1039
1151
|
|
|
1040
|
-
The platform includes 8 specialized agents
|
|
1041
|
-
|
|
1042
|
-
| ID | Domain |
|
|
1043
|
-
|
|
1044
|
-
| `governing` | Orchestration |
|
|
1045
|
-
| `
|
|
1046
|
-
| `
|
|
1047
|
-
| `
|
|
1048
|
-
| `
|
|
1049
|
-
| `
|
|
1050
|
-
| `
|
|
1051
|
-
| `
|
|
1152
|
+
The platform includes 8 specialized agents:
|
|
1153
|
+
|
|
1154
|
+
| ID | Domain | Role |
|
|
1155
|
+
|----|--------|------|
|
|
1156
|
+
| `governing` | Orchestration | The orchestrator: reasons over the goal, plans execution, dispatches subtasks to the other agents (and specialist subagents), and synthesizes the final answer |
|
|
1157
|
+
| `marketing` | Marketing & Content | Plans, creates, distributes, and optimizes content across all channels |
|
|
1158
|
+
| `sales` | Sales | Manages the revenue pipeline from inbound lead to closed deal |
|
|
1159
|
+
| `cx` | Customer Experience | Post-acquisition service, retention, and support quality |
|
|
1160
|
+
| `people` | People & Team | Employee lifecycle: hiring, onboarding, performance, scheduling |
|
|
1161
|
+
| `operations` | Operations | Internal execution infrastructure: tasks, SOPs, vendors, QA |
|
|
1162
|
+
| `inventory` | Inventory & Supply Chain | Stock levels, suppliers, reorder logic, delivery tracking |
|
|
1163
|
+
| `finance` | Finance | Invoices, P&L, cash flow, budgets, financial reporting |
|
|
1052
1164
|
|
|
1053
1165
|
Discover available capabilities at runtime:
|
|
1054
1166
|
```ts
|
package/dist/index.cjs
CHANGED
|
@@ -21,13 +21,21 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
23
|
API_ERROR_CODES: () => API_ERROR_CODES,
|
|
24
|
+
APPROVAL_STATUSES: () => APPROVAL_STATUSES,
|
|
24
25
|
AgentsApi: () => AgentsApi,
|
|
26
|
+
ApprovalsApi: () => ApprovalsApi,
|
|
25
27
|
AudioApi: () => AudioApi,
|
|
26
28
|
DEFAULT_BASE_URL: () => DEFAULT_BASE_URL,
|
|
29
|
+
EXECUTION_STATUSES: () => EXECUTION_STATUSES,
|
|
30
|
+
EventsApi: () => EventsApi,
|
|
31
|
+
ExecutionsApi: () => ExecutionsApi,
|
|
27
32
|
FilesApi: () => FilesApi,
|
|
28
33
|
ImagesApi: () => ImagesApi,
|
|
34
|
+
PoliciesApi: () => PoliciesApi,
|
|
29
35
|
QLClient: () => QLClient,
|
|
30
36
|
QLError: () => QLError,
|
|
37
|
+
SkillsApi: () => SkillsApi,
|
|
38
|
+
SubagentsApi: () => SubagentsApi,
|
|
31
39
|
TaskHandle: () => TaskHandle,
|
|
32
40
|
TasksApi: () => TasksApi,
|
|
33
41
|
VideoTaskHandle: () => VideoTaskHandle,
|
|
@@ -649,6 +657,115 @@ var FilesApi = class {
|
|
|
649
657
|
return result;
|
|
650
658
|
}
|
|
651
659
|
};
|
|
660
|
+
var ApprovalsApi = class {
|
|
661
|
+
constructor(t) {
|
|
662
|
+
this.t = t;
|
|
663
|
+
}
|
|
664
|
+
/** GET /api/v1/approvals — list policy approval requests (list-safe views, no payload). */
|
|
665
|
+
list(params) {
|
|
666
|
+
return this.t.json("GET", "/api/v1/approvals", {
|
|
667
|
+
query: {
|
|
668
|
+
status: params?.status?.join(","),
|
|
669
|
+
limit: params?.limit,
|
|
670
|
+
beforeCreatedAt: toIso(params?.beforeCreatedAt)
|
|
671
|
+
}
|
|
672
|
+
});
|
|
673
|
+
}
|
|
674
|
+
/** GET /api/v1/approvals/:id — full approval record incl. bound payload + evidence. */
|
|
675
|
+
get(approvalId) {
|
|
676
|
+
return this.t.json("GET", `/api/v1/approvals/${encodeURIComponent(approvalId)}`);
|
|
677
|
+
}
|
|
678
|
+
/** POST /api/v1/approvals/:id/decide — record an authorized workspace member's decision. */
|
|
679
|
+
decide(approvalId, input) {
|
|
680
|
+
return this.t.json("POST", `/api/v1/approvals/${encodeURIComponent(approvalId)}/decide`, { body: input });
|
|
681
|
+
}
|
|
682
|
+
/** POST /api/v1/approvals/:id/execute — execute the bound action of an approved approval, exactly once. */
|
|
683
|
+
execute(approvalId) {
|
|
684
|
+
return this.t.json("POST", `/api/v1/approvals/${encodeURIComponent(approvalId)}/execute`);
|
|
685
|
+
}
|
|
686
|
+
};
|
|
687
|
+
var PoliciesApi = class {
|
|
688
|
+
constructor(t) {
|
|
689
|
+
this.t = t;
|
|
690
|
+
}
|
|
691
|
+
/** GET /api/v1/policies — active rule packs with their rules + documented roadmap packs. */
|
|
692
|
+
get() {
|
|
693
|
+
return this.t.json("GET", "/api/v1/policies");
|
|
694
|
+
}
|
|
695
|
+
};
|
|
696
|
+
var EventsApi = class {
|
|
697
|
+
constructor(t) {
|
|
698
|
+
this.t = t;
|
|
699
|
+
}
|
|
700
|
+
/** GET /api/v1/events — paginated ledger read, newest first (`beforeSeq` pages backwards). */
|
|
701
|
+
list(params) {
|
|
702
|
+
return this.t.json("GET", "/api/v1/events", {
|
|
703
|
+
query: { limit: params?.limit, beforeSeq: params?.beforeSeq, types: params?.types?.join(",") }
|
|
704
|
+
});
|
|
705
|
+
}
|
|
706
|
+
/** GET /api/v1/events/verify — recompute every hash and check each prevHash link (audit retrieval). */
|
|
707
|
+
verify(params) {
|
|
708
|
+
return this.t.json("GET", "/api/v1/events/verify", { query: { afterSeq: params?.afterSeq } });
|
|
709
|
+
}
|
|
710
|
+
/** GET /api/v1/events/retention — retention report (no automatic deletion runs). */
|
|
711
|
+
retention() {
|
|
712
|
+
return this.t.json("GET", "/api/v1/events/retention");
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
var SubagentsApi = class {
|
|
716
|
+
constructor(t) {
|
|
717
|
+
this.t = t;
|
|
718
|
+
}
|
|
719
|
+
/** GET /api/v1/subagents — specialist definitions + honest stats (optionally filtered by owning agent). */
|
|
720
|
+
list(agentId) {
|
|
721
|
+
return this.t.json("GET", "/api/v1/subagents", { query: { agentId } });
|
|
722
|
+
}
|
|
723
|
+
/** GET /api/v1/subagents/:id — one specialist definition. */
|
|
724
|
+
get(subagentId) {
|
|
725
|
+
return this.t.json("GET", `/api/v1/subagents/${encodeURIComponent(subagentId)}`);
|
|
726
|
+
}
|
|
727
|
+
};
|
|
728
|
+
var SkillsApi = class {
|
|
729
|
+
constructor(t) {
|
|
730
|
+
this.t = t;
|
|
731
|
+
}
|
|
732
|
+
/** GET /api/v1/skills — skill definitions (no implementation functions) + honest stats. */
|
|
733
|
+
list(domain) {
|
|
734
|
+
return this.t.json("GET", "/api/v1/skills", { query: { domain } });
|
|
735
|
+
}
|
|
736
|
+
/** GET /api/v1/skills/:id — one skill definition. */
|
|
737
|
+
get(skillId) {
|
|
738
|
+
return this.t.json("GET", `/api/v1/skills/${encodeURIComponent(skillId)}`);
|
|
739
|
+
}
|
|
740
|
+
/** POST /api/v1/skills/run — run a skill through the full validation → authorization → policy → audit → execution pipeline. */
|
|
741
|
+
run(input) {
|
|
742
|
+
return this.t.json("POST", "/api/v1/skills/run", { body: input });
|
|
743
|
+
}
|
|
744
|
+
};
|
|
745
|
+
var ExecutionsApi = class {
|
|
746
|
+
constructor(t) {
|
|
747
|
+
this.t = t;
|
|
748
|
+
}
|
|
749
|
+
/** GET /api/v1/executions — execution history (list-safe views, no tool-call log). */
|
|
750
|
+
list(params) {
|
|
751
|
+
return this.t.json("GET", "/api/v1/executions", {
|
|
752
|
+
query: {
|
|
753
|
+
agentId: params?.agentId,
|
|
754
|
+
status: params?.status?.join(","),
|
|
755
|
+
limit: params?.limit,
|
|
756
|
+
beforeCreatedAt: toIso(params?.beforeCreatedAt)
|
|
757
|
+
}
|
|
758
|
+
});
|
|
759
|
+
}
|
|
760
|
+
/** GET /api/v1/executions/:id — full execution trace incl. tool calls + direct children. */
|
|
761
|
+
get(executionId) {
|
|
762
|
+
return this.t.json("GET", `/api/v1/executions/${encodeURIComponent(executionId)}`);
|
|
763
|
+
}
|
|
764
|
+
};
|
|
765
|
+
function toIso(value) {
|
|
766
|
+
if (value === void 0) return void 0;
|
|
767
|
+
return value instanceof Date ? value.toISOString() : value;
|
|
768
|
+
}
|
|
652
769
|
function readEnvBaseUrl() {
|
|
653
770
|
try {
|
|
654
771
|
if (typeof process !== "undefined" && process?.env) {
|
|
@@ -673,6 +790,12 @@ var QLClient = class {
|
|
|
673
790
|
this.images = new ImagesApi(this.transport);
|
|
674
791
|
this.videos = new VideosApi(this.transport);
|
|
675
792
|
this.audio = new AudioApi(this.transport);
|
|
793
|
+
this.approvals = new ApprovalsApi(this.transport);
|
|
794
|
+
this.policies = new PoliciesApi(this.transport);
|
|
795
|
+
this.events = new EventsApi(this.transport);
|
|
796
|
+
this.subagents = new SubagentsApi(this.transport);
|
|
797
|
+
this.skills = new SkillsApi(this.transport);
|
|
798
|
+
this.executions = new ExecutionsApi(this.transport);
|
|
676
799
|
this.files = new FilesApi(this.transport);
|
|
677
800
|
}
|
|
678
801
|
/** The normalized base URL in use (not secret). */
|
|
@@ -690,4 +813,14 @@ var API_ERROR_CODES = {
|
|
|
690
813
|
conflict: "conflict",
|
|
691
814
|
internalError: "internal_error"
|
|
692
815
|
};
|
|
816
|
+
var APPROVAL_STATUSES = [
|
|
817
|
+
"pending",
|
|
818
|
+
"approved",
|
|
819
|
+
"rejected",
|
|
820
|
+
"expired",
|
|
821
|
+
"consumed",
|
|
822
|
+
"invalidated",
|
|
823
|
+
"cancelled"
|
|
824
|
+
];
|
|
825
|
+
var EXECUTION_STATUSES = ["running", "completed", "failed", "cancelled", "timeout"];
|
|
693
826
|
//# sourceMappingURL=index.cjs.map
|