@oqtopus-team/qdash-client 1.10.5 → 1.10.6-beta.1306
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/{api-D8mi0whQ.d.ts → api-Cb2eb_Ck.d.ts} +34 -2
- package/dist/{chunk-3TJ5CDP7.js → chunk-HN7FHEGV.js} +152 -2
- package/dist/chunk-HN7FHEGV.js.map +1 -0
- package/dist/generated/api.d.ts +2 -2
- package/dist/generated/api.js +1 -1
- package/dist/index.d.ts +185 -9
- package/dist/index.js +225 -22
- package/dist/index.js.map +1 -1
- package/dist/models.d.ts +2 -2
- package/dist/{validatePipelineResponse-Cm-f-9gP.d.ts → validatePipelineResponse-buGT0E0k.d.ts} +3615 -282
- package/package.json +1 -1
- package/dist/chunk-3TJ5CDP7.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
QDashTransportError,
|
|
9
9
|
QDashValidationError,
|
|
10
10
|
getQDashAPI
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-HN7FHEGV.js";
|
|
12
12
|
|
|
13
13
|
// src/client.ts
|
|
14
14
|
import { setTimeout as sleep2 } from "timers/promises";
|
|
@@ -278,7 +278,8 @@ var QDashTransport = class {
|
|
|
278
278
|
url: path,
|
|
279
279
|
params: options.query,
|
|
280
280
|
data: options.body,
|
|
281
|
-
...options.headers ? { headers: Object.fromEntries(new Headers(options.headers).entries()) } : {}
|
|
281
|
+
...options.headers ? { headers: Object.fromEntries(new Headers(options.headers).entries()) } : {},
|
|
282
|
+
...options.signal ? { signal: options.signal } : {}
|
|
282
283
|
});
|
|
283
284
|
}
|
|
284
285
|
async request(config) {
|
|
@@ -310,7 +311,8 @@ var QDashTransport = class {
|
|
|
310
311
|
const response = await this.fetch(url, {
|
|
311
312
|
method: config.method ?? "GET",
|
|
312
313
|
headers,
|
|
313
|
-
...body === void 0 ? {} : { body }
|
|
314
|
+
...body === void 0 ? {} : { body },
|
|
315
|
+
...config.signal ? { signal: config.signal } : {}
|
|
314
316
|
});
|
|
315
317
|
let payload;
|
|
316
318
|
if (config.responseType === "arraybuffer") payload = await response.arrayBuffer();
|
|
@@ -341,6 +343,7 @@ var QDashTransport = class {
|
|
|
341
343
|
await this.sleep(this.retryDelayMilliseconds(attempt, response));
|
|
342
344
|
} catch (cause) {
|
|
343
345
|
if (cause instanceof QDashApiError) throw cause;
|
|
346
|
+
if (authenticated.signal.aborted) throw authenticated.signal.reason ?? cause;
|
|
344
347
|
if (attempt === attempts) {
|
|
345
348
|
throw new QDashTransportError("QDash request failed", { cause });
|
|
346
349
|
}
|
|
@@ -428,12 +431,55 @@ var QDashTransport = class {
|
|
|
428
431
|
};
|
|
429
432
|
|
|
430
433
|
// src/client.ts
|
|
434
|
+
var TASK_RESULTS_MAX_PAGE_SIZE = 100;
|
|
435
|
+
var TASK_RESULTS_MAX_COLLECT = 1e4;
|
|
431
436
|
function pathPart(value) {
|
|
432
437
|
return encodeURIComponent(value);
|
|
433
438
|
}
|
|
434
439
|
function query(values) {
|
|
435
440
|
return Object.fromEntries(Object.entries(values).filter(([, value]) => value != null));
|
|
436
441
|
}
|
|
442
|
+
var TASK_RESULTS_PAGE_HINT = "QDash returns at most 100 task results per request; use collectTaskResults({ maxItems }) or request further pages with skip";
|
|
443
|
+
function checkInteger(name, value, minimum, maximum, hint) {
|
|
444
|
+
if (value === void 0) return;
|
|
445
|
+
if (Number.isInteger(value) && value >= minimum && (maximum === void 0 || value <= maximum)) return;
|
|
446
|
+
const range = maximum === void 0 ? `${minimum} or more` : `from ${minimum} to ${maximum}`;
|
|
447
|
+
throw new QDashValidationError(
|
|
448
|
+
`${name} must be an integer ${range} (got ${String(value)})${hint ? `. ${hint}.` : "."}`,
|
|
449
|
+
{ payload: { field: name, value } }
|
|
450
|
+
);
|
|
451
|
+
}
|
|
452
|
+
function taskResultQuery(options) {
|
|
453
|
+
return query({
|
|
454
|
+
chip_id: options.chipId,
|
|
455
|
+
task_name: options.taskName,
|
|
456
|
+
qid: options.qid,
|
|
457
|
+
execution_id: options.executionId,
|
|
458
|
+
username: options.username,
|
|
459
|
+
status: options.status,
|
|
460
|
+
start_from: options.startFrom,
|
|
461
|
+
start_to: options.startTo,
|
|
462
|
+
message_contains: options.messageContains,
|
|
463
|
+
step_id: options.stepId,
|
|
464
|
+
call_id: options.callId,
|
|
465
|
+
limit: options.limit,
|
|
466
|
+
skip: options.skip
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
function checkTaskResultPage(payload) {
|
|
470
|
+
const page = payload;
|
|
471
|
+
const problems = [];
|
|
472
|
+
if (!page || typeof page !== "object") problems.push("the body is not an object");
|
|
473
|
+
else {
|
|
474
|
+
if (!Array.isArray(page.items)) problems.push("items is not an array");
|
|
475
|
+
else if (page.items.some((item) => !item || typeof item.task_id !== "string")) problems.push("an item has no task_id");
|
|
476
|
+
if (!Number.isInteger(page.total)) problems.push("total is not an integer");
|
|
477
|
+
}
|
|
478
|
+
if (problems.length > 0) {
|
|
479
|
+
throw new QDashApiError(`Unexpected GET /task-results response: ${problems.join("; ")}`, { payload });
|
|
480
|
+
}
|
|
481
|
+
return page;
|
|
482
|
+
}
|
|
437
483
|
function filenameFromPath(path) {
|
|
438
484
|
return path.split("/").filter(Boolean).at(-1);
|
|
439
485
|
}
|
|
@@ -473,6 +519,10 @@ var QDashClient = class _QDashClient {
|
|
|
473
519
|
withProject(projectId) {
|
|
474
520
|
return new _QDashClient(new QDashConfig({ ...this.config, projectId }), this.options);
|
|
475
521
|
}
|
|
522
|
+
/** The user QDash authenticated for this client's credentials. */
|
|
523
|
+
async getCurrentUser() {
|
|
524
|
+
return this.get("/auth/me");
|
|
525
|
+
}
|
|
476
526
|
async listChips() {
|
|
477
527
|
return this.get("/chips");
|
|
478
528
|
}
|
|
@@ -521,21 +571,71 @@ var QDashClient = class _QDashClient {
|
|
|
521
571
|
})
|
|
522
572
|
);
|
|
523
573
|
}
|
|
574
|
+
/**
|
|
575
|
+
* One page of task results. `limit` must be an integer from 1 to 100 and
|
|
576
|
+
* `skip` an integer of 0 or more; other values throw `QDashValidationError`
|
|
577
|
+
* before any request, never a silently smaller page. Use
|
|
578
|
+
* `collectTaskResults` to read more than 100 rows.
|
|
579
|
+
*/
|
|
524
580
|
async listTaskResults(options = {}) {
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
581
|
+
checkInteger("limit", options.limit, 1, TASK_RESULTS_MAX_PAGE_SIZE, TASK_RESULTS_PAGE_HINT);
|
|
582
|
+
checkInteger("skip", options.skip, 0, void 0);
|
|
583
|
+
const payload = await this.transport.requestJson("GET", "/task-results", {
|
|
584
|
+
query: taskResultQuery(options),
|
|
585
|
+
...options.signal ? { signal: options.signal } : {}
|
|
586
|
+
});
|
|
587
|
+
return checkTaskResultPage(payload);
|
|
588
|
+
}
|
|
589
|
+
/**
|
|
590
|
+
* Up to `maxItems` task results matching the filters, read in pages of at
|
|
591
|
+
* most 100 from `skip` (default 0), newest first, with every filter on each
|
|
592
|
+
* page. Reading stops at `maxItems`, at the last matching row, or at a short
|
|
593
|
+
* page, with at most `ceil(maxItems / pageSize)` page reads. Duplicates can
|
|
594
|
+
* therefore leave fewer than `maxItems` rows and set `truncated`.
|
|
595
|
+
* A failed or cancelled page rejects the whole call; no partial result
|
|
596
|
+
* is returned as complete. Pages are offsets, not a snapshot: a result
|
|
597
|
+
* written while reading can shift rows, so rows are deduplicated by
|
|
598
|
+
* `task_id`.
|
|
599
|
+
*/
|
|
600
|
+
async collectTaskResults(options) {
|
|
601
|
+
const { maxItems, pageSize = TASK_RESULTS_MAX_PAGE_SIZE, ...filters } = options;
|
|
602
|
+
checkInteger("maxItems", maxItems, 1, TASK_RESULTS_MAX_COLLECT);
|
|
603
|
+
checkInteger("pageSize", pageSize, 1, TASK_RESULTS_MAX_PAGE_SIZE, TASK_RESULTS_PAGE_HINT);
|
|
604
|
+
checkInteger("skip", filters.skip, 0, void 0);
|
|
605
|
+
const start = filters.skip ?? 0;
|
|
606
|
+
const items = [];
|
|
607
|
+
const seen = /* @__PURE__ */ new Set();
|
|
608
|
+
let offset = start;
|
|
609
|
+
let pages = 0;
|
|
610
|
+
let last;
|
|
611
|
+
const maxPages = Math.ceil(maxItems / pageSize);
|
|
612
|
+
let duplicates = false;
|
|
613
|
+
while (items.length < maxItems && pages < maxPages) {
|
|
614
|
+
filters.signal?.throwIfAborted();
|
|
615
|
+
const limit = Math.min(pageSize, maxItems - items.length);
|
|
616
|
+
const page = await this.listTaskResults({ ...filters, skip: offset, limit });
|
|
617
|
+
pages += 1;
|
|
618
|
+
last = page;
|
|
619
|
+
for (const item of page.items) {
|
|
620
|
+
if (seen.has(item.task_id)) {
|
|
621
|
+
duplicates = true;
|
|
622
|
+
continue;
|
|
623
|
+
}
|
|
624
|
+
seen.add(item.task_id);
|
|
625
|
+
items.push(item);
|
|
626
|
+
}
|
|
627
|
+
offset += page.items.length;
|
|
628
|
+
if (page.items.length < limit || offset >= page.total) break;
|
|
629
|
+
}
|
|
630
|
+
const total = last?.total ?? 0;
|
|
631
|
+
return {
|
|
632
|
+
items,
|
|
633
|
+
total,
|
|
634
|
+
skip: start,
|
|
635
|
+
pages,
|
|
636
|
+
truncated: duplicates || offset < total,
|
|
637
|
+
status_counts: last?.status_counts ?? {}
|
|
638
|
+
};
|
|
539
639
|
}
|
|
540
640
|
async getTaskResult(taskId) {
|
|
541
641
|
return this.get(`/tasks/${pathPart(taskId)}/result`);
|
|
@@ -780,12 +880,37 @@ var QDashClient = class _QDashClient {
|
|
|
780
880
|
skill_name: options.skillName ?? "",
|
|
781
881
|
skill_version: options.skillVersion ?? "",
|
|
782
882
|
skill_hash: options.skillHash ?? "",
|
|
783
|
-
|
|
883
|
+
...options.model ? { model: options.model } : {}
|
|
784
884
|
});
|
|
785
885
|
}
|
|
886
|
+
/** The project's agent sessions, newest first, with expiry applied before filtering. */
|
|
887
|
+
async listAgentSessions(options = {}) {
|
|
888
|
+
const payload = await this.get(
|
|
889
|
+
"/agent-sessions",
|
|
890
|
+
query({
|
|
891
|
+
chip_id: options.chipId,
|
|
892
|
+
status: options.statuses,
|
|
893
|
+
mine: options.mine,
|
|
894
|
+
limit: options.limit
|
|
895
|
+
})
|
|
896
|
+
);
|
|
897
|
+
return payload.items;
|
|
898
|
+
}
|
|
786
899
|
async getAgentSession(sessionId) {
|
|
787
900
|
return this.get(`/agent-sessions/${pathPart(sessionId)}`);
|
|
788
901
|
}
|
|
902
|
+
/**
|
|
903
|
+
* End an active or paused session's authority on a person's request (`POST
|
|
904
|
+
* /agent-sessions/{id}/stop`). The response is QDash's own account: whether this request
|
|
905
|
+
* stopped it, and the operations that passed the session gate before and still run;
|
|
906
|
+
* QDash does not cancel those.
|
|
907
|
+
*/
|
|
908
|
+
async stopAgentSession(sessionId, options) {
|
|
909
|
+
return this.post(`/agent-sessions/${pathPart(sessionId)}/stop`, {
|
|
910
|
+
idempotency_key: options.idempotencyKey,
|
|
911
|
+
reason: options.reason
|
|
912
|
+
});
|
|
913
|
+
}
|
|
789
914
|
async evaluateAgentCandidateGate(sessionId, parameterName, value) {
|
|
790
915
|
return this.post(`/agent-sessions/${pathPart(sessionId)}/candidate-gate`, {
|
|
791
916
|
parameter_name: parameterName,
|
|
@@ -800,7 +925,10 @@ var QDashClient = class _QDashClient {
|
|
|
800
925
|
task_name: options.taskName ?? null,
|
|
801
926
|
qids: options.qids ?? [],
|
|
802
927
|
parameter_overrides: options.parameterOverrides ?? {},
|
|
803
|
-
diagnosis: options.diagnosis ?? ""
|
|
928
|
+
diagnosis: options.diagnosis ?? "",
|
|
929
|
+
...options.autonomous ? { autonomous: true } : {},
|
|
930
|
+
...options.repeatOfActionId ? { repeat_of_action_id: options.repeatOfActionId } : {},
|
|
931
|
+
...options.model ? { model: options.model } : {}
|
|
804
932
|
});
|
|
805
933
|
}
|
|
806
934
|
/**
|
|
@@ -813,13 +941,83 @@ var QDashClient = class _QDashClient {
|
|
|
813
941
|
{
|
|
814
942
|
...options.sourceExecutionId ? { source_execution_id: options.sourceExecutionId } : {},
|
|
815
943
|
update_params: options.updateParams ?? false,
|
|
816
|
-
reconfigure: options.reconfigure ?? false
|
|
944
|
+
reconfigure: options.reconfigure ?? false,
|
|
945
|
+
...options.autonomous ? { autonomous: true } : {}
|
|
817
946
|
}
|
|
818
947
|
);
|
|
819
948
|
}
|
|
820
949
|
async getAgentAction(sessionId, actionId) {
|
|
821
950
|
return this.get(`/agent-sessions/${pathPart(sessionId)}/actions/${pathPart(actionId)}`);
|
|
822
951
|
}
|
|
952
|
+
/** A session's interventions, newest first: why the agent stopped and the expert's answer. */
|
|
953
|
+
async listAgentInterventions(sessionId) {
|
|
954
|
+
const payload = await this.get(
|
|
955
|
+
`/agent-sessions/${pathPart(sessionId)}/interventions`
|
|
956
|
+
);
|
|
957
|
+
return payload.items;
|
|
958
|
+
}
|
|
959
|
+
/**
|
|
960
|
+
* Record that the agent stopped and needs a person. An active session pauses until an
|
|
961
|
+
* expert answers in QDash; a repeated idempotency key returns the same record. The
|
|
962
|
+
* request carries no plan checkpoint, so the expert's resume reactivates the session.
|
|
963
|
+
*/
|
|
964
|
+
async createAgentIntervention(sessionId, options) {
|
|
965
|
+
return this.post(`/agent-sessions/${pathPart(sessionId)}/interventions`, {
|
|
966
|
+
idempotency_key: options.idempotencyKey,
|
|
967
|
+
reason: options.reason,
|
|
968
|
+
summary: options.summary,
|
|
969
|
+
question: options.question,
|
|
970
|
+
...options.taskName ? { task_name: options.taskName } : {},
|
|
971
|
+
qids: options.qids ?? [],
|
|
972
|
+
attempts: options.attempts ?? [],
|
|
973
|
+
...options.previousInterventionId ? { previous_intervention_id: options.previousInterventionId } : {},
|
|
974
|
+
...options.autonomous ? { autonomous: true } : {},
|
|
975
|
+
...options.model ? { model: options.model } : {}
|
|
976
|
+
});
|
|
977
|
+
}
|
|
978
|
+
async getAgentIntervention(sessionId, interventionId) {
|
|
979
|
+
return this.get(
|
|
980
|
+
`/agent-sessions/${pathPart(sessionId)}/interventions/${pathPart(interventionId)}`
|
|
981
|
+
);
|
|
982
|
+
}
|
|
983
|
+
/**
|
|
984
|
+
* Append the agent's reading of a result and its next step to the session's audit. Only
|
|
985
|
+
* the session's creator records decisions; recording changes no session state, so it works
|
|
986
|
+
* in a paused or ended session too. A repeated idempotency key returns the same record.
|
|
987
|
+
*/
|
|
988
|
+
async recordAgentDecision(sessionId, options) {
|
|
989
|
+
return this.post(`/agent-sessions/${pathPart(sessionId)}/decisions`, {
|
|
990
|
+
idempotency_key: options.idempotencyKey,
|
|
991
|
+
...options.assessment ? { assessment: options.assessment } : {},
|
|
992
|
+
interpretation: options.interpretation,
|
|
993
|
+
next_action: options.nextAction,
|
|
994
|
+
next_detail: options.nextDetail ?? "",
|
|
995
|
+
evidence_action_ids: options.evidenceActionIds ?? [],
|
|
996
|
+
evaluation_ids: options.evaluationIds ?? [],
|
|
997
|
+
...options.nextActionId ? { next_action_id: options.nextActionId } : {},
|
|
998
|
+
...options.interventionId ? { intervention_id: options.interventionId } : {},
|
|
999
|
+
...options.supersedesDecisionId ? { supersedes_decision_id: options.supersedesDecisionId } : {},
|
|
1000
|
+
...options.model ? { model: options.model } : {}
|
|
1001
|
+
});
|
|
1002
|
+
}
|
|
1003
|
+
/** A session's recorded decisions, oldest first. */
|
|
1004
|
+
async listAgentDecisions(sessionId) {
|
|
1005
|
+
const payload = await this.get(
|
|
1006
|
+
`/agent-sessions/${pathPart(sessionId)}/decisions`
|
|
1007
|
+
);
|
|
1008
|
+
return payload.items;
|
|
1009
|
+
}
|
|
1010
|
+
/** One page of a session's chronological audit; follow `next_cursor` until `complete`. */
|
|
1011
|
+
async getAgentSessionAudit(sessionId, options = {}) {
|
|
1012
|
+
return this.get(
|
|
1013
|
+
`/agent-sessions/${pathPart(sessionId)}/audit`,
|
|
1014
|
+
query({ cursor: options.cursor, limit: options.limit })
|
|
1015
|
+
);
|
|
1016
|
+
}
|
|
1017
|
+
/** The whole audit as versioned JSON; QDash refuses (413) rather than truncates it. */
|
|
1018
|
+
async exportAgentSessionAudit(sessionId) {
|
|
1019
|
+
return this.get(`/agent-sessions/${pathPart(sessionId)}/audit/export`);
|
|
1020
|
+
}
|
|
823
1021
|
async listAgentActions(sessionId) {
|
|
824
1022
|
const payload = await this.get(
|
|
825
1023
|
`/agent-sessions/${pathPart(sessionId)}/actions`
|
|
@@ -849,7 +1047,9 @@ var QDashClient = class _QDashClient {
|
|
|
849
1047
|
{
|
|
850
1048
|
idempotency_key: options.idempotencyKey,
|
|
851
1049
|
expected_state_version: options.expectedStateVersion,
|
|
852
|
-
task_id: options.taskId
|
|
1050
|
+
task_id: options.taskId,
|
|
1051
|
+
// Sent only when set, so a reviewed request keeps its earlier shape.
|
|
1052
|
+
...options.autonomous ? { autonomous: true, decision_id: options.decisionId } : {}
|
|
853
1053
|
}
|
|
854
1054
|
);
|
|
855
1055
|
}
|
|
@@ -874,7 +1074,8 @@ var QDashClient = class _QDashClient {
|
|
|
874
1074
|
{
|
|
875
1075
|
idempotency_key: options.idempotencyKey,
|
|
876
1076
|
expected_state_version: options.expectedStateVersion,
|
|
877
|
-
push_to_github: options.pushToGithub ?? false
|
|
1077
|
+
push_to_github: options.pushToGithub ?? false,
|
|
1078
|
+
...options.autonomous ? { autonomous: true } : {}
|
|
878
1079
|
}
|
|
879
1080
|
);
|
|
880
1081
|
}
|
|
@@ -1036,6 +1237,8 @@ export {
|
|
|
1036
1237
|
QDashTimeoutError,
|
|
1037
1238
|
QDashTransportError,
|
|
1038
1239
|
QDashValidationError,
|
|
1240
|
+
TASK_RESULTS_MAX_COLLECT,
|
|
1241
|
+
TASK_RESULTS_MAX_PAGE_SIZE,
|
|
1039
1242
|
defaultConfigPath,
|
|
1040
1243
|
getQDashAPI
|
|
1041
1244
|
};
|