@wave-ai-os/wave-cli 0.1.82 → 0.1.84
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.cjs +503 -27
- package/dist/index.js +501 -25
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -1220,6 +1220,7 @@ var RESOURCE_QUERY_FIELDS = {
|
|
|
1220
1220
|
"organizationSlug",
|
|
1221
1221
|
"userId",
|
|
1222
1222
|
"coachId",
|
|
1223
|
+
"reportTo",
|
|
1223
1224
|
"timezone",
|
|
1224
1225
|
"province",
|
|
1225
1226
|
"birthdate",
|
|
@@ -7900,7 +7901,7 @@ var import_commander = require("commander");
|
|
|
7900
7901
|
var import_node_crypto3 = require("crypto");
|
|
7901
7902
|
|
|
7902
7903
|
// src/version.ts
|
|
7903
|
-
var CLI_VERSION = "0.1.
|
|
7904
|
+
var CLI_VERSION = "0.1.84";
|
|
7904
7905
|
|
|
7905
7906
|
// src/operationMetadata.ts
|
|
7906
7907
|
var DISCOVERY_OPERATION_IDS = [
|
|
@@ -8360,6 +8361,7 @@ var WRITE_OPERATION_IDS = [
|
|
|
8360
8361
|
"todos.create",
|
|
8361
8362
|
"todos.update"
|
|
8362
8363
|
];
|
|
8364
|
+
var DIRECT_MACHINE_WRITE_OPERATION_IDS = /* @__PURE__ */ new Set(["automations.create"]);
|
|
8363
8365
|
var AUTH_OPERATION_IDS = ["login", "logout"];
|
|
8364
8366
|
var DESTRUCTIVE_OPERATION_IDS = /* @__PURE__ */ new Set([
|
|
8365
8367
|
"content.destroy",
|
|
@@ -8403,7 +8405,7 @@ for (const [classification, operationIds] of Object.entries(OPERATION_IDS_BY_CLA
|
|
|
8403
8405
|
}
|
|
8404
8406
|
metadataByOperationId.set(id, {
|
|
8405
8407
|
classification,
|
|
8406
|
-
requiresApproval: classification === "write",
|
|
8408
|
+
requiresApproval: classification === "write" && !DIRECT_MACHINE_WRITE_OPERATION_IDS.has(id),
|
|
8407
8409
|
atlasSafetyClass,
|
|
8408
8410
|
machine: {
|
|
8409
8411
|
supportsValidate: true,
|
|
@@ -15729,9 +15731,481 @@ function registerDatasheetsCommands(program) {
|
|
|
15729
15731
|
});
|
|
15730
15732
|
}
|
|
15731
15733
|
|
|
15734
|
+
// src/commands/signatures.ts
|
|
15735
|
+
var import_node_path4 = require("path");
|
|
15736
|
+
var import_promises4 = require("fs/promises");
|
|
15737
|
+
var import_node_crypto4 = require("crypto");
|
|
15738
|
+
var import_pdf_lib = require("pdf-lib");
|
|
15739
|
+
var idSchema14 = (value, label = "id") => {
|
|
15740
|
+
const parsed = typeof value === "string" ? value.trim() : "";
|
|
15741
|
+
if (parsed.length === 0) {
|
|
15742
|
+
throw new CliError({
|
|
15743
|
+
message: label + " is required.",
|
|
15744
|
+
kind: "invalid_args",
|
|
15745
|
+
status: 400,
|
|
15746
|
+
exitCode: EXIT_CODES.invalidArgs
|
|
15747
|
+
});
|
|
15748
|
+
}
|
|
15749
|
+
return parsed;
|
|
15750
|
+
};
|
|
15751
|
+
var MAX_SIGNATURE_PDF_BYTES = 50 * 1024 * 1024;
|
|
15752
|
+
var URL_OR_TRANSPORT_KEY = /(?:^|_)(?:url|uri|token|nonce|post_fields|postfields|headers|authorization|secret|credential)(?:$|_)/i;
|
|
15753
|
+
function isRecord7(value) {
|
|
15754
|
+
return Boolean(value) && typeof value === "object" && !Array.isArray(value);
|
|
15755
|
+
}
|
|
15756
|
+
function asNonEmptyString6(value) {
|
|
15757
|
+
if (typeof value !== "string") return null;
|
|
15758
|
+
const trimmed = value.trim();
|
|
15759
|
+
return trimmed.length > 0 ? trimmed : null;
|
|
15760
|
+
}
|
|
15761
|
+
function parseJsonObject4(raw, optionName) {
|
|
15762
|
+
try {
|
|
15763
|
+
const parsed = JSON.parse(raw);
|
|
15764
|
+
if (!isRecord7(parsed)) {
|
|
15765
|
+
throw new Error("JSON must be an object.");
|
|
15766
|
+
}
|
|
15767
|
+
return parsed;
|
|
15768
|
+
} catch (error) {
|
|
15769
|
+
throw new CliError({
|
|
15770
|
+
message: error instanceof Error ? "Invalid " + optionName + ": " + error.message : "Invalid " + optionName + ".",
|
|
15771
|
+
kind: "invalid_args",
|
|
15772
|
+
status: 400,
|
|
15773
|
+
exitCode: EXIT_CODES.invalidArgs
|
|
15774
|
+
});
|
|
15775
|
+
}
|
|
15776
|
+
}
|
|
15777
|
+
function unwrapSignaturePayload(raw) {
|
|
15778
|
+
const wrapped = raw.signature_envelope ?? raw.signatureEnvelope ?? raw.signature ?? raw.envelope;
|
|
15779
|
+
return isRecord7(wrapped) ? wrapped : raw;
|
|
15780
|
+
}
|
|
15781
|
+
function onlyAllowedKeys(payload, allowed, optionName) {
|
|
15782
|
+
const unsupported = Object.keys(payload).filter((key) => !allowed.includes(key));
|
|
15783
|
+
if (unsupported.length > 0) {
|
|
15784
|
+
throw new CliError({
|
|
15785
|
+
message: "Invalid " + optionName + ": unsupported fields " + unsupported.join(", ") + ".",
|
|
15786
|
+
kind: "invalid_args",
|
|
15787
|
+
status: 400,
|
|
15788
|
+
exitCode: EXIT_CODES.invalidArgs,
|
|
15789
|
+
details: { unsupportedFields: unsupported, allowedFields: allowed }
|
|
15790
|
+
});
|
|
15791
|
+
}
|
|
15792
|
+
return payload;
|
|
15793
|
+
}
|
|
15794
|
+
function parseCreatePayload(raw, mode) {
|
|
15795
|
+
const data = raw ? unwrapSignaturePayload(parseJsonObject4(raw, "--data-json")) : {};
|
|
15796
|
+
onlyAllowedKeys(
|
|
15797
|
+
data,
|
|
15798
|
+
["name", "subject", "message", "expires_at", "visibility", "metadata", "recipients"],
|
|
15799
|
+
"--data-json"
|
|
15800
|
+
);
|
|
15801
|
+
const parsedMode = asNonEmptyString6(mode);
|
|
15802
|
+
if (parsedMode !== "request" && parsedMode !== "self_sign") {
|
|
15803
|
+
throw new CliError({
|
|
15804
|
+
message: "signatures create requires --mode request or --mode self_sign.",
|
|
15805
|
+
kind: "invalid_args",
|
|
15806
|
+
status: 400,
|
|
15807
|
+
exitCode: EXIT_CODES.invalidArgs
|
|
15808
|
+
});
|
|
15809
|
+
}
|
|
15810
|
+
return { ...data, mode: parsedMode };
|
|
15811
|
+
}
|
|
15812
|
+
function parseUpdatePayload(raw, options) {
|
|
15813
|
+
const data = raw ? unwrapSignaturePayload(parseJsonObject4(raw, "--data-json")) : {};
|
|
15814
|
+
onlyAllowedKeys(
|
|
15815
|
+
data,
|
|
15816
|
+
["name", "subject", "message", "expires_at", "visibility", "recipients", "fields"],
|
|
15817
|
+
"--data-json"
|
|
15818
|
+
);
|
|
15819
|
+
const name = asNonEmptyString6(options.name);
|
|
15820
|
+
const subject = asNonEmptyString6(options.subject);
|
|
15821
|
+
const message = asNonEmptyString6(options.message);
|
|
15822
|
+
const patch = {
|
|
15823
|
+
...data,
|
|
15824
|
+
...name ? { name } : {},
|
|
15825
|
+
...subject ? { subject } : {},
|
|
15826
|
+
...message ? { message } : {}
|
|
15827
|
+
};
|
|
15828
|
+
if (Object.keys(patch).length === 0) {
|
|
15829
|
+
throw new CliError({
|
|
15830
|
+
message: "signatures update requires --data-json, --name, --subject, or --message.",
|
|
15831
|
+
kind: "invalid_args",
|
|
15832
|
+
status: 400,
|
|
15833
|
+
exitCode: EXIT_CODES.invalidArgs
|
|
15834
|
+
});
|
|
15835
|
+
}
|
|
15836
|
+
return patch;
|
|
15837
|
+
}
|
|
15838
|
+
function sanitizeSignatureValue(value) {
|
|
15839
|
+
if (Array.isArray(value)) return value.map(sanitizeSignatureValue);
|
|
15840
|
+
if (!isRecord7(value)) return value;
|
|
15841
|
+
return Object.fromEntries(
|
|
15842
|
+
Object.entries(value).filter(([key]) => {
|
|
15843
|
+
const normalizedKey2 = key.replace(/([a-z0-9])([A-Z])/g, "$1_$2");
|
|
15844
|
+
return !URL_OR_TRANSPORT_KEY.test(normalizedKey2);
|
|
15845
|
+
}).map(([key, child]) => [key, sanitizeSignatureValue(child)])
|
|
15846
|
+
);
|
|
15847
|
+
}
|
|
15848
|
+
function safeSignatureMutationPayload(payload) {
|
|
15849
|
+
if (!isRecord7(payload)) return payload;
|
|
15850
|
+
return {
|
|
15851
|
+
...payload,
|
|
15852
|
+
...Object.prototype.hasOwnProperty.call(payload, "data") ? { data: sanitizeSignatureValue(payload.data) } : {}
|
|
15853
|
+
};
|
|
15854
|
+
}
|
|
15855
|
+
function safeSignatureQueryPayload(payload) {
|
|
15856
|
+
return sanitizeSignatureValue(payload);
|
|
15857
|
+
}
|
|
15858
|
+
function cliErrorEnvelope(command, error) {
|
|
15859
|
+
return {
|
|
15860
|
+
ok: false,
|
|
15861
|
+
command,
|
|
15862
|
+
status: error.status,
|
|
15863
|
+
data: null,
|
|
15864
|
+
error: {
|
|
15865
|
+
code: error.kind,
|
|
15866
|
+
message: error.message,
|
|
15867
|
+
details: error.details
|
|
15868
|
+
},
|
|
15869
|
+
meta: { requestId: "local_error" }
|
|
15870
|
+
};
|
|
15871
|
+
}
|
|
15872
|
+
async function inspectSignaturePdf(path) {
|
|
15873
|
+
const resolvedPath = idSchema14(path, "file");
|
|
15874
|
+
const filename = (0, import_node_path4.basename)(resolvedPath);
|
|
15875
|
+
if (!filename.toLowerCase().endsWith(".pdf")) {
|
|
15876
|
+
throw new CliError({
|
|
15877
|
+
message: "Signature source files must have a .pdf extension.",
|
|
15878
|
+
kind: "invalid_args",
|
|
15879
|
+
status: 400,
|
|
15880
|
+
exitCode: EXIT_CODES.invalidArgs
|
|
15881
|
+
});
|
|
15882
|
+
}
|
|
15883
|
+
let bytes;
|
|
15884
|
+
try {
|
|
15885
|
+
bytes = await (0, import_promises4.readFile)(resolvedPath);
|
|
15886
|
+
} catch (error) {
|
|
15887
|
+
throw new CliError({
|
|
15888
|
+
message: "Unable to read the Signature PDF: " + (error instanceof Error ? error.message : "unknown error"),
|
|
15889
|
+
kind: "invalid_args",
|
|
15890
|
+
status: 400,
|
|
15891
|
+
exitCode: EXIT_CODES.invalidArgs
|
|
15892
|
+
});
|
|
15893
|
+
}
|
|
15894
|
+
if (bytes.byteLength === 0 || bytes.byteLength > MAX_SIGNATURE_PDF_BYTES) {
|
|
15895
|
+
throw new CliError({
|
|
15896
|
+
message: "Signature PDFs must be between 1 byte and 50 MB.",
|
|
15897
|
+
kind: "invalid_args",
|
|
15898
|
+
status: 400,
|
|
15899
|
+
exitCode: EXIT_CODES.invalidArgs
|
|
15900
|
+
});
|
|
15901
|
+
}
|
|
15902
|
+
if (Buffer.from(bytes).subarray(0, 5).toString("ascii") !== "%PDF-") {
|
|
15903
|
+
throw new CliError({
|
|
15904
|
+
message: "Only valid PDF documents can be used for signatures.",
|
|
15905
|
+
kind: "invalid_args",
|
|
15906
|
+
status: 400,
|
|
15907
|
+
exitCode: EXIT_CODES.invalidArgs
|
|
15908
|
+
});
|
|
15909
|
+
}
|
|
15910
|
+
let pageCount;
|
|
15911
|
+
try {
|
|
15912
|
+
const document = await import_pdf_lib.PDFDocument.load(bytes, { ignoreEncryption: false });
|
|
15913
|
+
pageCount = document.getPageCount();
|
|
15914
|
+
} catch {
|
|
15915
|
+
throw new CliError({
|
|
15916
|
+
message: "Only valid, non-password-protected PDF documents can be used for signatures.",
|
|
15917
|
+
kind: "invalid_args",
|
|
15918
|
+
status: 400,
|
|
15919
|
+
exitCode: EXIT_CODES.invalidArgs
|
|
15920
|
+
});
|
|
15921
|
+
}
|
|
15922
|
+
if (pageCount < 1 || pageCount > 500) {
|
|
15923
|
+
throw new CliError({
|
|
15924
|
+
message: "Signature PDFs must contain between 1 and 500 pages.",
|
|
15925
|
+
kind: "invalid_args",
|
|
15926
|
+
status: 400,
|
|
15927
|
+
exitCode: EXIT_CODES.invalidArgs
|
|
15928
|
+
});
|
|
15929
|
+
}
|
|
15930
|
+
return {
|
|
15931
|
+
bytes,
|
|
15932
|
+
filename,
|
|
15933
|
+
byteSize: bytes.byteLength,
|
|
15934
|
+
pageCount,
|
|
15935
|
+
sha256: (0, import_node_crypto4.createHash)("sha256").update(bytes).digest("hex")
|
|
15936
|
+
};
|
|
15937
|
+
}
|
|
15938
|
+
function requireUploadTarget(payload) {
|
|
15939
|
+
if (!isRecord7(payload) || !isRecord7(payload.data) || !isRecord7(payload.data.data)) {
|
|
15940
|
+
throw new CliError({
|
|
15941
|
+
message: "Signature upload initialization returned an invalid payload.",
|
|
15942
|
+
kind: "malformed_response",
|
|
15943
|
+
status: 502,
|
|
15944
|
+
exitCode: EXIT_CODES.networkOrUpstream
|
|
15945
|
+
});
|
|
15946
|
+
}
|
|
15947
|
+
const attributes = payload.data.data.attributes;
|
|
15948
|
+
if (!isRecord7(attributes)) {
|
|
15949
|
+
throw new CliError({
|
|
15950
|
+
message: "Signature upload initialization did not return upload attributes.",
|
|
15951
|
+
kind: "malformed_response",
|
|
15952
|
+
status: 502,
|
|
15953
|
+
exitCode: EXIT_CODES.networkOrUpstream
|
|
15954
|
+
});
|
|
15955
|
+
}
|
|
15956
|
+
const postUrl = asNonEmptyString6(attributes.postUrl);
|
|
15957
|
+
const fileKey = asNonEmptyString6(attributes.getUrl);
|
|
15958
|
+
const rawPostFields = attributes.postFields;
|
|
15959
|
+
if (!postUrl || !fileKey || !isRecord7(rawPostFields) || !fileKey.startsWith("uploads/signatures/")) {
|
|
15960
|
+
throw new CliError({
|
|
15961
|
+
message: "Signature upload initialization returned an invalid storage target.",
|
|
15962
|
+
kind: "malformed_response",
|
|
15963
|
+
status: 502,
|
|
15964
|
+
exitCode: EXIT_CODES.networkOrUpstream
|
|
15965
|
+
});
|
|
15966
|
+
}
|
|
15967
|
+
const postFields = Object.entries(rawPostFields).reduce((result, [key, value]) => {
|
|
15968
|
+
if (typeof value === "string") result[key] = value;
|
|
15969
|
+
return result;
|
|
15970
|
+
}, {});
|
|
15971
|
+
if (Object.keys(postFields).length === 0) {
|
|
15972
|
+
throw new CliError({
|
|
15973
|
+
message: "Signature upload initialization returned no upload form fields.",
|
|
15974
|
+
kind: "malformed_response",
|
|
15975
|
+
status: 502,
|
|
15976
|
+
exitCode: EXIT_CODES.networkOrUpstream
|
|
15977
|
+
});
|
|
15978
|
+
}
|
|
15979
|
+
return { postUrl, postFields, fileKey };
|
|
15980
|
+
}
|
|
15981
|
+
async function uploadSignaturePdf(target, pdf) {
|
|
15982
|
+
const form = new FormData();
|
|
15983
|
+
Object.entries(target.postFields).forEach(([key, value]) => form.set(key, value));
|
|
15984
|
+
const uploadBytes = new Uint8Array(pdf.bytes.byteLength);
|
|
15985
|
+
uploadBytes.set(pdf.bytes);
|
|
15986
|
+
form.set("file", new Blob([uploadBytes.buffer], { type: "application/pdf" }), pdf.filename);
|
|
15987
|
+
let response;
|
|
15988
|
+
try {
|
|
15989
|
+
response = await fetch(target.postUrl, { method: "POST", body: form });
|
|
15990
|
+
} catch (error) {
|
|
15991
|
+
throw new CliError({
|
|
15992
|
+
message: "Signature PDF upload failed: " + (error instanceof Error ? error.message : "network error"),
|
|
15993
|
+
kind: "network_error",
|
|
15994
|
+
status: 502,
|
|
15995
|
+
exitCode: EXIT_CODES.networkOrUpstream
|
|
15996
|
+
});
|
|
15997
|
+
}
|
|
15998
|
+
if (!response.ok) {
|
|
15999
|
+
throw new CliError({
|
|
16000
|
+
message: "Signature PDF upload failed with HTTP " + response.status + ".",
|
|
16001
|
+
kind: "upstream_error",
|
|
16002
|
+
status: 502,
|
|
16003
|
+
exitCode: EXIT_CODES.networkOrUpstream
|
|
16004
|
+
});
|
|
16005
|
+
}
|
|
16006
|
+
}
|
|
16007
|
+
async function runCreateSignatureCommand(params) {
|
|
16008
|
+
try {
|
|
16009
|
+
const config = getConfig(params.runtimeOptions);
|
|
16010
|
+
const pdf = await inspectSignaturePdf(params.file);
|
|
16011
|
+
const uploadResult = await graphqlRequest({
|
|
16012
|
+
config,
|
|
16013
|
+
command: "signatures.create.upload",
|
|
16014
|
+
operationName: "SignaturesCreateUpload",
|
|
16015
|
+
operationType: "mutation",
|
|
16016
|
+
field: "create_s3_upload",
|
|
16017
|
+
variables: {
|
|
16018
|
+
params: {
|
|
16019
|
+
filename: pdf.filename,
|
|
16020
|
+
file_type: "pdf",
|
|
16021
|
+
content_type: "application/pdf",
|
|
16022
|
+
directory: "signatures"
|
|
16023
|
+
}
|
|
16024
|
+
},
|
|
16025
|
+
variableTypes: { params: "CreateS3UploadParamsInput!" },
|
|
16026
|
+
selectionSet: "{ ok status errorCode data errors }"
|
|
16027
|
+
});
|
|
16028
|
+
if (!uploadResult.envelope.ok) {
|
|
16029
|
+
return printEnvelopeAndExit({
|
|
16030
|
+
envelope: uploadResult.envelope,
|
|
16031
|
+
exitCode: uploadResult.exitCode
|
|
16032
|
+
});
|
|
16033
|
+
}
|
|
16034
|
+
const uploadPayload = uploadResult.envelope.data?.create_s3_upload;
|
|
16035
|
+
const target = requireUploadTarget(uploadPayload);
|
|
16036
|
+
await uploadSignaturePdf(target, pdf);
|
|
16037
|
+
const createResult = await graphqlRequest({
|
|
16038
|
+
config,
|
|
16039
|
+
command: "signatures.create",
|
|
16040
|
+
operationName: "SignaturesCreate",
|
|
16041
|
+
operationType: "mutation",
|
|
16042
|
+
field: "create_signature_envelope",
|
|
16043
|
+
variables: {
|
|
16044
|
+
organization_id: params.organizationId,
|
|
16045
|
+
params: {
|
|
16046
|
+
...params.payload,
|
|
16047
|
+
file_key: target.fileKey,
|
|
16048
|
+
filename: pdf.filename,
|
|
16049
|
+
byte_size: pdf.byteSize,
|
|
16050
|
+
page_count: pdf.pageCount,
|
|
16051
|
+
sha256: pdf.sha256
|
|
16052
|
+
}
|
|
16053
|
+
},
|
|
16054
|
+
variableTypes: {
|
|
16055
|
+
organization_id: "ID!",
|
|
16056
|
+
params: "JSON!"
|
|
16057
|
+
},
|
|
16058
|
+
selectionSet: "{ ok status errorCode data errors }"
|
|
16059
|
+
});
|
|
16060
|
+
if (createResult.envelope.ok && createResult.envelope.data) {
|
|
16061
|
+
const data = createResult.envelope.data;
|
|
16062
|
+
createResult.envelope.data = {
|
|
16063
|
+
...data,
|
|
16064
|
+
create_signature_envelope: safeSignatureMutationPayload(data.create_signature_envelope)
|
|
16065
|
+
};
|
|
16066
|
+
}
|
|
16067
|
+
return printEnvelopeAndExit({
|
|
16068
|
+
envelope: createResult.envelope,
|
|
16069
|
+
exitCode: createResult.exitCode
|
|
16070
|
+
});
|
|
16071
|
+
} catch (error) {
|
|
16072
|
+
if (error instanceof CliError) {
|
|
16073
|
+
return printEnvelopeAndExit({
|
|
16074
|
+
envelope: cliErrorEnvelope("signatures.create", error),
|
|
16075
|
+
exitCode: error.exitCode
|
|
16076
|
+
});
|
|
16077
|
+
}
|
|
16078
|
+
throw error;
|
|
16079
|
+
}
|
|
16080
|
+
}
|
|
16081
|
+
function requireConfirmation(value, optionName) {
|
|
16082
|
+
if (value === true) return;
|
|
16083
|
+
throw new CliError({
|
|
16084
|
+
message: "This Signature action requires " + optionName + ".",
|
|
16085
|
+
kind: "invalid_args",
|
|
16086
|
+
status: 400,
|
|
16087
|
+
exitCode: EXIT_CODES.invalidArgs
|
|
16088
|
+
});
|
|
16089
|
+
}
|
|
16090
|
+
function registerSignatureCommands(program) {
|
|
16091
|
+
const signatures = program.command("signatures").description("Signature envelope operations");
|
|
16092
|
+
signatures.command("list").option("--folder <folder>").option("--status <status>").option("--query <query>").option("--mine").option("--page <page>").option("--per <per>").action(async (opts, cmd) => {
|
|
16093
|
+
const context = await resolveCommandContext(cmd.optsWithGlobals());
|
|
16094
|
+
const organizationId = resolveOrganizationId(context.organizationId);
|
|
16095
|
+
await runGraphqlQueryCommand({
|
|
16096
|
+
command: "signatures.list",
|
|
16097
|
+
operationName: "SignaturesList",
|
|
16098
|
+
runtimeOptions: context.runtimeOptions,
|
|
16099
|
+
field: "signature_envelopes",
|
|
16100
|
+
variables: {
|
|
16101
|
+
organization_id: organizationId,
|
|
16102
|
+
params: normalizeGraphqlVariables2({
|
|
16103
|
+
folder: opts.folder,
|
|
16104
|
+
status: opts.status,
|
|
16105
|
+
query: opts.query,
|
|
16106
|
+
mine: opts.mine,
|
|
16107
|
+
page: opts.page,
|
|
16108
|
+
per: opts.per
|
|
16109
|
+
})
|
|
16110
|
+
},
|
|
16111
|
+
variableTypes: { organization_id: "ID!", params: "JSON" },
|
|
16112
|
+
selectionSet: "",
|
|
16113
|
+
isList: true,
|
|
16114
|
+
transformData: safeSignatureQueryPayload
|
|
16115
|
+
});
|
|
16116
|
+
});
|
|
16117
|
+
signatures.command("show").requiredOption("--id <id>").option("--include-events").action(async (opts, cmd) => {
|
|
16118
|
+
const context = await resolveCommandContext(cmd.optsWithGlobals());
|
|
16119
|
+
const organizationId = resolveOrganizationId(context.organizationId);
|
|
16120
|
+
await runGraphqlQueryCommand({
|
|
16121
|
+
command: "signatures.show",
|
|
16122
|
+
operationName: "SignaturesShow",
|
|
16123
|
+
runtimeOptions: context.runtimeOptions,
|
|
16124
|
+
field: "signature_envelope",
|
|
16125
|
+
variables: {
|
|
16126
|
+
organization_id: organizationId,
|
|
16127
|
+
id: idSchema14(opts.id),
|
|
16128
|
+
include_events: Boolean(opts.includeEvents)
|
|
16129
|
+
},
|
|
16130
|
+
variableTypes: {
|
|
16131
|
+
organization_id: "ID!",
|
|
16132
|
+
id: "ID!",
|
|
16133
|
+
include_events: "Boolean!"
|
|
16134
|
+
},
|
|
16135
|
+
selectionSet: "",
|
|
16136
|
+
isShow: true,
|
|
16137
|
+
transformData: safeSignatureQueryPayload
|
|
16138
|
+
});
|
|
16139
|
+
});
|
|
16140
|
+
signatures.command("create").requiredOption("--file <file>").requiredOption("--mode <mode>", "request or self_sign").option("--data-json <dataJson>", "JSON object for additional draft fields").action(async (opts, cmd) => {
|
|
16141
|
+
const context = await resolveCommandContext(cmd.optsWithGlobals());
|
|
16142
|
+
await runCreateSignatureCommand({
|
|
16143
|
+
runtimeOptions: context.runtimeOptions,
|
|
16144
|
+
organizationId: resolveOrganizationId(context.organizationId),
|
|
16145
|
+
file: String(opts.file),
|
|
16146
|
+
payload: parseCreatePayload(opts.dataJson, opts.mode)
|
|
16147
|
+
});
|
|
16148
|
+
});
|
|
16149
|
+
signatures.command("update").requiredOption("--id <id>").option("--name <name>").option("--subject <subject>").option("--message <message>").option("--data-json <dataJson>", "JSON object for draft fields, recipients, and fields").action(async (opts, cmd) => {
|
|
16150
|
+
const context = await resolveCommandContext(cmd.optsWithGlobals());
|
|
16151
|
+
const organizationId = resolveOrganizationId(context.organizationId);
|
|
16152
|
+
await runGraphqlMutationCommand({
|
|
16153
|
+
command: "signatures.update",
|
|
16154
|
+
operationName: "SignaturesUpdate",
|
|
16155
|
+
runtimeOptions: context.runtimeOptions,
|
|
16156
|
+
field: "update_signature_envelope",
|
|
16157
|
+
variables: {
|
|
16158
|
+
organization_id: organizationId,
|
|
16159
|
+
id: idSchema14(opts.id),
|
|
16160
|
+
params: parseUpdatePayload(opts.dataJson, opts)
|
|
16161
|
+
},
|
|
16162
|
+
variableTypes: {
|
|
16163
|
+
organization_id: "ID!",
|
|
16164
|
+
id: "ID!",
|
|
16165
|
+
params: "JSON!"
|
|
16166
|
+
},
|
|
16167
|
+
transformMutationPayload: safeSignatureMutationPayload
|
|
16168
|
+
});
|
|
16169
|
+
});
|
|
16170
|
+
const lifecycle = (name, field, confirmation) => {
|
|
16171
|
+
const command = signatures.command(name).requiredOption("--id <id>");
|
|
16172
|
+
if (name === "void") command.requiredOption("--reason <reason>");
|
|
16173
|
+
if (confirmation === "--confirm-send") command.option("--confirm-send");
|
|
16174
|
+
if (confirmation === "--confirm") command.option("--confirm");
|
|
16175
|
+
command.action(async (opts, cmd) => {
|
|
16176
|
+
if (confirmation === "--confirm-send") requireConfirmation(opts.confirmSend, "--confirm-send");
|
|
16177
|
+
if (confirmation === "--confirm") requireConfirmation(opts.confirm, "--confirm");
|
|
16178
|
+
const context = await resolveCommandContext(cmd.optsWithGlobals());
|
|
16179
|
+
const organizationId = resolveOrganizationId(context.organizationId);
|
|
16180
|
+
await runGraphqlMutationCommand({
|
|
16181
|
+
command: "signatures." + name,
|
|
16182
|
+
operationName: "Signatures" + name.slice(0, 1).toUpperCase() + name.slice(1),
|
|
16183
|
+
runtimeOptions: context.runtimeOptions,
|
|
16184
|
+
field,
|
|
16185
|
+
variables: {
|
|
16186
|
+
organization_id: organizationId,
|
|
16187
|
+
id: idSchema14(opts.id),
|
|
16188
|
+
...name === "void" ? { reason: idSchema14(opts.reason, "reason") } : {}
|
|
16189
|
+
},
|
|
16190
|
+
variableTypes: {
|
|
16191
|
+
organization_id: "ID!",
|
|
16192
|
+
id: "ID!",
|
|
16193
|
+
...name === "void" ? { reason: "String" } : {}
|
|
16194
|
+
},
|
|
16195
|
+
transformMutationPayload: safeSignatureMutationPayload
|
|
16196
|
+
});
|
|
16197
|
+
});
|
|
16198
|
+
};
|
|
16199
|
+
lifecycle("send", "send_signature_envelope", "--confirm-send");
|
|
16200
|
+
lifecycle("archive", "archive_signature_envelope", null);
|
|
16201
|
+
lifecycle("unarchive", "unarchive_signature_envelope", null);
|
|
16202
|
+
lifecycle("destroy", "delete_signature_envelope", "--confirm");
|
|
16203
|
+
lifecycle("void", "void_signature_envelope", "--confirm");
|
|
16204
|
+
}
|
|
16205
|
+
|
|
15732
16206
|
// src/commands/atlasAuthoring.ts
|
|
15733
16207
|
var import_zod20 = require("zod");
|
|
15734
|
-
var
|
|
16208
|
+
var idSchema15 = import_zod20.z.string().trim().min(1);
|
|
15735
16209
|
var idempotencyKeySchema = import_zod20.z.string().min(1).refine((value) => value.trim() === value, "Idempotency key must not have leading or trailing whitespace.");
|
|
15736
16210
|
var skillScopeSchema = import_zod20.z.enum(["ADMIN_GLOBAL", "MEMBER_PERSONAL"]);
|
|
15737
16211
|
var isoDateSchema = import_zod20.z.iso.date();
|
|
@@ -15803,7 +16277,6 @@ var AGENT_SELECTION = `{
|
|
|
15803
16277
|
slug
|
|
15804
16278
|
status
|
|
15805
16279
|
visibility
|
|
15806
|
-
model
|
|
15807
16280
|
runWhenMentioned
|
|
15808
16281
|
webAccessEnabled
|
|
15809
16282
|
webFetchEnabled
|
|
@@ -16084,6 +16557,7 @@ function normalizePersistedCreatePayload(payload) {
|
|
|
16084
16557
|
const mutationData = asRecord7(mutation?.data);
|
|
16085
16558
|
const persisted = asRecord7(mutationData?.data) ?? mutationData;
|
|
16086
16559
|
const attributes = asRecord7(persisted?.attributes);
|
|
16560
|
+
const automationExecution = asRecord7(attributes?.automation_execution) ?? asRecord7(attributes?.automationExecution);
|
|
16087
16561
|
const meta = asRecord7(mutationData?.meta);
|
|
16088
16562
|
const idempotency = asRecord7(meta?.atlas_idempotency);
|
|
16089
16563
|
const id = asRequiredString(persisted?.id);
|
|
@@ -16111,7 +16585,8 @@ function normalizePersistedCreatePayload(payload) {
|
|
|
16111
16585
|
fingerprint: asRequiredString(idempotency.fingerprint),
|
|
16112
16586
|
replay,
|
|
16113
16587
|
action: asRequiredString(idempotency.action)
|
|
16114
|
-
}
|
|
16588
|
+
},
|
|
16589
|
+
...automationExecution ? { automation_execution: automationExecution } : {}
|
|
16115
16590
|
};
|
|
16116
16591
|
}
|
|
16117
16592
|
function normalizePersistedUpdatePayload(payload) {
|
|
@@ -16263,7 +16738,7 @@ function parseAutomationConfig(value) {
|
|
|
16263
16738
|
exitCode: EXIT_CODES.invalidArgs
|
|
16264
16739
|
});
|
|
16265
16740
|
}
|
|
16266
|
-
return config;
|
|
16741
|
+
return config.cycle === "single" ? { ...config, cycle: "single_use" } : config;
|
|
16267
16742
|
}
|
|
16268
16743
|
function parseExpectedUpdateVersion(value) {
|
|
16269
16744
|
return nonEmptyStringSchema.parse(String(value));
|
|
@@ -16333,7 +16808,7 @@ function registerAtlasAuthoringCommands(program) {
|
|
|
16333
16808
|
...opts.name !== void 0 ? { name: String(opts.name) } : {},
|
|
16334
16809
|
...opts.description !== void 0 ? { description: String(opts.description) } : {},
|
|
16335
16810
|
...opts.notes !== void 0 ? { notes: String(opts.notes) } : {},
|
|
16336
|
-
...opts.memberId !== void 0 ? { member_id:
|
|
16811
|
+
...opts.memberId !== void 0 ? { member_id: idSchema15.parse(opts.memberId) } : {},
|
|
16337
16812
|
...opts.status !== void 0 ? { status: String(opts.status) } : {},
|
|
16338
16813
|
...opts.visibility !== void 0 ? { visibility: String(opts.visibility) } : {},
|
|
16339
16814
|
...opts.model !== void 0 ? { model: String(opts.model) } : {},
|
|
@@ -16356,7 +16831,7 @@ function registerAtlasAuthoringCommands(program) {
|
|
|
16356
16831
|
});
|
|
16357
16832
|
});
|
|
16358
16833
|
agents.command("show").description("Read one persisted Agent by id or slug").requiredOption("--id <idOrSlug>", "Agent id or slug").action(async (opts, cmd) => {
|
|
16359
|
-
const id =
|
|
16834
|
+
const id = idSchema15.parse(opts.id);
|
|
16360
16835
|
const context = await resolveCommandContext(cmd.optsWithGlobals());
|
|
16361
16836
|
const organizationId = resolveOrganizationId(context.organizationId);
|
|
16362
16837
|
await runGraphqlQueryCommand({
|
|
@@ -16444,7 +16919,7 @@ function registerAtlasAuthoringCommands(program) {
|
|
|
16444
16919
|
exitCode: EXIT_CODES.invalidArgs
|
|
16445
16920
|
});
|
|
16446
16921
|
}
|
|
16447
|
-
const id =
|
|
16922
|
+
const id = idSchema15.parse(opts.id);
|
|
16448
16923
|
const expectedUpdateVersion = parseExpectedUpdateVersion(opts.expectedUpdateVersion);
|
|
16449
16924
|
const context = await resolveCommandContext(cmd.optsWithGlobals());
|
|
16450
16925
|
const organizationId = resolveOrganizationId(context.organizationId);
|
|
@@ -16528,12 +17003,12 @@ function registerAtlasAuthoringCommands(program) {
|
|
|
16528
17003
|
variables: {
|
|
16529
17004
|
organization_id: organizationId,
|
|
16530
17005
|
input: {
|
|
16531
|
-
summary:
|
|
17006
|
+
summary: idSchema15.parse(opts.summary),
|
|
16532
17007
|
ai_task_config: parseAutomationConfig(opts.aiTaskConfig),
|
|
16533
17008
|
...opts.description !== void 0 ? { description: String(opts.description) } : {},
|
|
16534
17009
|
...opts.notes !== void 0 ? { notes: String(opts.notes) } : {},
|
|
16535
|
-
...opts.memberId !== void 0 ? { member_id:
|
|
16536
|
-
...opts.agentId !== void 0 ? { agent_id:
|
|
17010
|
+
...opts.memberId !== void 0 ? { member_id: idSchema15.parse(opts.memberId) } : {},
|
|
17011
|
+
...opts.agentId !== void 0 ? { agent_id: idSchema15.parse(opts.agentId) } : {},
|
|
16537
17012
|
...opts.priority !== void 0 ? { priority: String(opts.priority) } : {},
|
|
16538
17013
|
...opts.dueDate !== void 0 ? { due_date: isoDateSchema.parse(opts.dueDate) } : {}
|
|
16539
17014
|
},
|
|
@@ -16543,7 +17018,7 @@ function registerAtlasAuthoringCommands(program) {
|
|
|
16543
17018
|
});
|
|
16544
17019
|
});
|
|
16545
17020
|
automations.command("show").description("Read one persisted Automation by id or slug").requiredOption("--id <idOrSlug>", "Automation id or slug").action(async (opts, cmd) => {
|
|
16546
|
-
const id =
|
|
17021
|
+
const id = idSchema15.parse(opts.id);
|
|
16547
17022
|
const context = await resolveCommandContext(cmd.optsWithGlobals());
|
|
16548
17023
|
const organizationId = resolveOrganizationId(context.organizationId);
|
|
16549
17024
|
await runGraphqlQueryCommand({
|
|
@@ -16558,7 +17033,7 @@ function registerAtlasAuthoringCommands(program) {
|
|
|
16558
17033
|
});
|
|
16559
17034
|
});
|
|
16560
17035
|
automations.command("run").description("Queue one Automation by id or slug and return exact status readback identifiers").requiredOption("--id <idOrSlug>", "Automation id or slug").action(async (opts, cmd) => {
|
|
16561
|
-
const automationId =
|
|
17036
|
+
const automationId = idSchema15.parse(opts.id);
|
|
16562
17037
|
const context = await resolveCommandContext(cmd.optsWithGlobals());
|
|
16563
17038
|
const organizationId = resolveOrganizationId(context.organizationId);
|
|
16564
17039
|
await runGraphqlMutationCommand({
|
|
@@ -16572,9 +17047,9 @@ function registerAtlasAuthoringCommands(program) {
|
|
|
16572
17047
|
});
|
|
16573
17048
|
});
|
|
16574
17049
|
automations.command("run-status").description("Read one queued or terminal Automation execution by its run identity").requiredOption("--id <idOrSlug>", "Automation id or slug returned by automations run").requiredOption("--message-id <messageId>", "Message id returned by automations run").requiredOption("--run-id <runId>", "Run id returned by automations run").action(async (opts, cmd) => {
|
|
16575
|
-
const automationId =
|
|
16576
|
-
const messageId =
|
|
16577
|
-
const runId =
|
|
17050
|
+
const automationId = idSchema15.parse(opts.id);
|
|
17051
|
+
const messageId = idSchema15.parse(opts.messageId);
|
|
17052
|
+
const runId = idSchema15.parse(opts.runId);
|
|
16578
17053
|
const context = await resolveCommandContext(cmd.optsWithGlobals());
|
|
16579
17054
|
const organizationId = resolveOrganizationId(context.organizationId);
|
|
16580
17055
|
await runGraphqlQueryCommand({
|
|
@@ -16599,8 +17074,8 @@ function registerAtlasAuthoringCommands(program) {
|
|
|
16599
17074
|
});
|
|
16600
17075
|
});
|
|
16601
17076
|
automations.command("run-show").description("Read one Automation run artifact by Agent id and execution slug").requiredOption("--agent-id <agentIdOrSlug>", "Agent id or slug").requiredOption("--execution-slug <executionSlug>", "Execution slug returned by automations run").action(async (opts, cmd) => {
|
|
16602
|
-
const agentId =
|
|
16603
|
-
const executionSlug =
|
|
17077
|
+
const agentId = idSchema15.parse(opts.agentId);
|
|
17078
|
+
const executionSlug = idSchema15.parse(opts.executionSlug);
|
|
16604
17079
|
const context = await resolveCommandContext(cmd.optsWithGlobals());
|
|
16605
17080
|
const organizationId = resolveOrganizationId(context.organizationId);
|
|
16606
17081
|
await runGraphqlQueryCommand({
|
|
@@ -16654,7 +17129,7 @@ function registerAtlasAuthoringCommands(program) {
|
|
|
16654
17129
|
exitCode: EXIT_CODES.invalidArgs
|
|
16655
17130
|
});
|
|
16656
17131
|
}
|
|
16657
|
-
const id =
|
|
17132
|
+
const id = idSchema15.parse(opts.id);
|
|
16658
17133
|
const expectedUpdateVersion = parseExpectedUpdateVersion(opts.expectedUpdateVersion);
|
|
16659
17134
|
const context = await resolveCommandContext(cmd.optsWithGlobals());
|
|
16660
17135
|
const organizationId = resolveOrganizationId(context.organizationId);
|
|
@@ -16699,7 +17174,7 @@ function registerAtlasAuthoringCommands(program) {
|
|
|
16699
17174
|
variables: {
|
|
16700
17175
|
organization_id: organizationId,
|
|
16701
17176
|
input: {
|
|
16702
|
-
name:
|
|
17177
|
+
name: idSchema15.parse(opts.name),
|
|
16703
17178
|
scope: skillScopeSchema.parse(opts.scope),
|
|
16704
17179
|
...opts.emoji !== void 0 ? { emoji: String(opts.emoji) } : {},
|
|
16705
17180
|
...opts.description !== void 0 ? { description: String(opts.description) } : {}
|
|
@@ -16726,7 +17201,7 @@ function registerAtlasAuthoringCommands(program) {
|
|
|
16726
17201
|
exitCode: EXIT_CODES.invalidArgs
|
|
16727
17202
|
});
|
|
16728
17203
|
}
|
|
16729
|
-
const id =
|
|
17204
|
+
const id = idSchema15.parse(opts.id);
|
|
16730
17205
|
const expectedUpdateVersion = parseExpectedUpdateVersion(opts.expectedUpdateVersion);
|
|
16731
17206
|
const context = await resolveCommandContext(cmd.optsWithGlobals());
|
|
16732
17207
|
const organizationId = resolveOrganizationId(context.organizationId);
|
|
@@ -16754,7 +17229,7 @@ function registerAtlasAuthoringCommands(program) {
|
|
|
16754
17229
|
|
|
16755
17230
|
// src/commands/discovery.ts
|
|
16756
17231
|
var import_node_fs4 = require("fs");
|
|
16757
|
-
var
|
|
17232
|
+
var import_node_path5 = require("path");
|
|
16758
17233
|
var PRIMARY_NAMESPACES = [
|
|
16759
17234
|
"osmd",
|
|
16760
17235
|
"broadcast",
|
|
@@ -17394,7 +17869,7 @@ function commandSummary(command) {
|
|
|
17394
17869
|
}
|
|
17395
17870
|
function packageVersion() {
|
|
17396
17871
|
try {
|
|
17397
|
-
const pkg = JSON.parse((0, import_node_fs4.readFileSync)((0,
|
|
17872
|
+
const pkg = JSON.parse((0, import_node_fs4.readFileSync)((0, import_node_path5.join)(process.cwd(), "package.json"), "utf8"));
|
|
17398
17873
|
return typeof pkg.version === "string" ? pkg.version : "unknown";
|
|
17399
17874
|
} catch {
|
|
17400
17875
|
return "unknown";
|
|
@@ -17811,6 +18286,7 @@ function buildCli(options) {
|
|
|
17811
18286
|
registerMailCommands(program);
|
|
17812
18287
|
registerPhantomCommands(program);
|
|
17813
18288
|
registerDatasheetsCommands(program);
|
|
18289
|
+
registerSignatureCommands(program);
|
|
17814
18290
|
registerAuthCommands(program);
|
|
17815
18291
|
registerDiscoveryCommands(program);
|
|
17816
18292
|
attachNamespaceDiscovery(program);
|
|
@@ -17819,7 +18295,7 @@ function buildCli(options) {
|
|
|
17819
18295
|
}
|
|
17820
18296
|
|
|
17821
18297
|
// src/machine.ts
|
|
17822
|
-
var
|
|
18298
|
+
var import_node_crypto5 = require("crypto");
|
|
17823
18299
|
var import_node_fs5 = require("fs");
|
|
17824
18300
|
var MACHINE_FLAGS = /* @__PURE__ */ new Set([
|
|
17825
18301
|
"--machine",
|
|
@@ -17925,7 +18401,7 @@ async function readMachineInput(location) {
|
|
|
17925
18401
|
return parsed;
|
|
17926
18402
|
}
|
|
17927
18403
|
function inputDigest(input) {
|
|
17928
|
-
return `sha256:${(0,
|
|
18404
|
+
return `sha256:${(0, import_node_crypto5.createHash)("sha256").update(canonicalJson(input)).digest("hex")}`;
|
|
17929
18405
|
}
|
|
17930
18406
|
function canonicalJson(value) {
|
|
17931
18407
|
if (Array.isArray(value)) return `[${value.map(canonicalJson).join(",")}]`;
|
|
@@ -18256,7 +18732,7 @@ async function maybeRunMachineExecute(argv, program) {
|
|
|
18256
18732
|
exitCode: EXIT_CODES.missingOrInvalidAuth
|
|
18257
18733
|
});
|
|
18258
18734
|
}
|
|
18259
|
-
if (resolved.operation.
|
|
18735
|
+
if (resolved.operation.requiresApproval) {
|
|
18260
18736
|
const approval = parseTrustedJsonFromFd(parsed.approvalFd, isTrustedApproval);
|
|
18261
18737
|
if (!approval || approval.operation !== resolved.operation.id || approval.inputDigest !== digest || approval.cliVersion !== manifest.cli.version || approval.registryDigest !== manifest.registryDigest || approval.organizationId !== auth?.organizationId || approval.actorId !== auth?.actorId) {
|
|
18262
18738
|
return printEnvelopeAndExit({
|