@vk007/autocli 0.1.0 → 0.1.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/dist/index.js +626 -227
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -9917,7 +9917,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
9917
9917
|
return new impl(doc2, localName, prefix);
|
|
9918
9918
|
};
|
|
9919
9919
|
function define2(spec) {
|
|
9920
|
-
return defineElement(spec,
|
|
9920
|
+
return defineElement(spec, HTMLElement2, htmlElements, htmlNameToImpl);
|
|
9921
9921
|
}
|
|
9922
9922
|
function URL2(attr) {
|
|
9923
9923
|
return {
|
|
@@ -9969,10 +9969,10 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
9969
9969
|
COMMAND: true
|
|
9970
9970
|
};
|
|
9971
9971
|
var HTMLFormElement = function(doc2, localName, prefix) {
|
|
9972
|
-
|
|
9972
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
9973
9973
|
this._form = null;
|
|
9974
9974
|
};
|
|
9975
|
-
var
|
|
9975
|
+
var HTMLElement2 = exports.HTMLElement = define2({
|
|
9976
9976
|
superclass: Element,
|
|
9977
9977
|
name: "HTMLElement",
|
|
9978
9978
|
ctor: function HTMLElement(doc2, localName, prefix) {
|
|
@@ -10113,7 +10113,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10113
10113
|
var HTMLUnknownElement = define2({
|
|
10114
10114
|
name: "HTMLUnknownElement",
|
|
10115
10115
|
ctor: function HTMLUnknownElement(doc2, localName, prefix) {
|
|
10116
|
-
|
|
10116
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10117
10117
|
}
|
|
10118
10118
|
});
|
|
10119
10119
|
var formAssociatedProps = {
|
|
@@ -10125,7 +10125,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10125
10125
|
tag: "a",
|
|
10126
10126
|
name: "HTMLAnchorElement",
|
|
10127
10127
|
ctor: function HTMLAnchorElement(doc2, localName, prefix) {
|
|
10128
|
-
|
|
10128
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10129
10129
|
},
|
|
10130
10130
|
props: {
|
|
10131
10131
|
_post_click_activation_steps: { value: function(e) {
|
|
@@ -10156,7 +10156,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10156
10156
|
tag: "area",
|
|
10157
10157
|
name: "HTMLAreaElement",
|
|
10158
10158
|
ctor: function HTMLAreaElement(doc2, localName, prefix) {
|
|
10159
|
-
|
|
10159
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10160
10160
|
},
|
|
10161
10161
|
attributes: {
|
|
10162
10162
|
alt: String,
|
|
@@ -10179,7 +10179,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10179
10179
|
tag: "br",
|
|
10180
10180
|
name: "HTMLBRElement",
|
|
10181
10181
|
ctor: function HTMLBRElement(doc2, localName, prefix) {
|
|
10182
|
-
|
|
10182
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10183
10183
|
},
|
|
10184
10184
|
attributes: {
|
|
10185
10185
|
clear: String
|
|
@@ -10189,7 +10189,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10189
10189
|
tag: "base",
|
|
10190
10190
|
name: "HTMLBaseElement",
|
|
10191
10191
|
ctor: function HTMLBaseElement(doc2, localName, prefix) {
|
|
10192
|
-
|
|
10192
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10193
10193
|
},
|
|
10194
10194
|
attributes: {
|
|
10195
10195
|
target: String
|
|
@@ -10199,7 +10199,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10199
10199
|
tag: "body",
|
|
10200
10200
|
name: "HTMLBodyElement",
|
|
10201
10201
|
ctor: function HTMLBodyElement(doc2, localName, prefix) {
|
|
10202
|
-
|
|
10202
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10203
10203
|
},
|
|
10204
10204
|
events: [
|
|
10205
10205
|
"afterprint",
|
|
@@ -10254,7 +10254,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10254
10254
|
tag: "dl",
|
|
10255
10255
|
name: "HTMLDListElement",
|
|
10256
10256
|
ctor: function HTMLDListElement(doc2, localName, prefix) {
|
|
10257
|
-
|
|
10257
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10258
10258
|
},
|
|
10259
10259
|
attributes: {
|
|
10260
10260
|
compact: Boolean
|
|
@@ -10264,7 +10264,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10264
10264
|
tag: "data",
|
|
10265
10265
|
name: "HTMLDataElement",
|
|
10266
10266
|
ctor: function HTMLDataElement(doc2, localName, prefix) {
|
|
10267
|
-
|
|
10267
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10268
10268
|
},
|
|
10269
10269
|
attributes: {
|
|
10270
10270
|
value: String
|
|
@@ -10274,14 +10274,14 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10274
10274
|
tag: "datalist",
|
|
10275
10275
|
name: "HTMLDataListElement",
|
|
10276
10276
|
ctor: function HTMLDataListElement(doc2, localName, prefix) {
|
|
10277
|
-
|
|
10277
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10278
10278
|
}
|
|
10279
10279
|
});
|
|
10280
10280
|
define2({
|
|
10281
10281
|
tag: "details",
|
|
10282
10282
|
name: "HTMLDetailsElement",
|
|
10283
10283
|
ctor: function HTMLDetailsElement(doc2, localName, prefix) {
|
|
10284
|
-
|
|
10284
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10285
10285
|
},
|
|
10286
10286
|
attributes: {
|
|
10287
10287
|
open: Boolean
|
|
@@ -10291,7 +10291,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10291
10291
|
tag: "div",
|
|
10292
10292
|
name: "HTMLDivElement",
|
|
10293
10293
|
ctor: function HTMLDivElement(doc2, localName, prefix) {
|
|
10294
|
-
|
|
10294
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10295
10295
|
},
|
|
10296
10296
|
attributes: {
|
|
10297
10297
|
align: String
|
|
@@ -10301,7 +10301,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10301
10301
|
tag: "embed",
|
|
10302
10302
|
name: "HTMLEmbedElement",
|
|
10303
10303
|
ctor: function HTMLEmbedElement(doc2, localName, prefix) {
|
|
10304
|
-
|
|
10304
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10305
10305
|
},
|
|
10306
10306
|
attributes: {
|
|
10307
10307
|
src: URL2,
|
|
@@ -10328,7 +10328,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10328
10328
|
tag: "form",
|
|
10329
10329
|
name: "HTMLFormElement",
|
|
10330
10330
|
ctor: function HTMLFormElement(doc2, localName, prefix) {
|
|
10331
|
-
|
|
10331
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10332
10332
|
},
|
|
10333
10333
|
attributes: {
|
|
10334
10334
|
action: String,
|
|
@@ -10346,7 +10346,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10346
10346
|
tag: "hr",
|
|
10347
10347
|
name: "HTMLHRElement",
|
|
10348
10348
|
ctor: function HTMLHRElement(doc2, localName, prefix) {
|
|
10349
|
-
|
|
10349
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10350
10350
|
},
|
|
10351
10351
|
attributes: {
|
|
10352
10352
|
align: String,
|
|
@@ -10360,14 +10360,14 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10360
10360
|
tag: "head",
|
|
10361
10361
|
name: "HTMLHeadElement",
|
|
10362
10362
|
ctor: function HTMLHeadElement(doc2, localName, prefix) {
|
|
10363
|
-
|
|
10363
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10364
10364
|
}
|
|
10365
10365
|
});
|
|
10366
10366
|
define2({
|
|
10367
10367
|
tags: ["h1", "h2", "h3", "h4", "h5", "h6"],
|
|
10368
10368
|
name: "HTMLHeadingElement",
|
|
10369
10369
|
ctor: function HTMLHeadingElement(doc2, localName, prefix) {
|
|
10370
|
-
|
|
10370
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10371
10371
|
},
|
|
10372
10372
|
attributes: {
|
|
10373
10373
|
align: String
|
|
@@ -10377,7 +10377,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10377
10377
|
tag: "html",
|
|
10378
10378
|
name: "HTMLHtmlElement",
|
|
10379
10379
|
ctor: function HTMLHtmlElement(doc2, localName, prefix) {
|
|
10380
|
-
|
|
10380
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10381
10381
|
},
|
|
10382
10382
|
attributes: {
|
|
10383
10383
|
xmlns: URL2,
|
|
@@ -10388,7 +10388,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10388
10388
|
tag: "iframe",
|
|
10389
10389
|
name: "HTMLIFrameElement",
|
|
10390
10390
|
ctor: function HTMLIFrameElement(doc2, localName, prefix) {
|
|
10391
|
-
|
|
10391
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10392
10392
|
},
|
|
10393
10393
|
attributes: {
|
|
10394
10394
|
src: URL2,
|
|
@@ -10415,7 +10415,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10415
10415
|
tag: "img",
|
|
10416
10416
|
name: "HTMLImageElement",
|
|
10417
10417
|
ctor: function HTMLImageElement(doc2, localName, prefix) {
|
|
10418
|
-
|
|
10418
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10419
10419
|
},
|
|
10420
10420
|
attributes: {
|
|
10421
10421
|
alt: String,
|
|
@@ -10540,7 +10540,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10540
10540
|
tag: "li",
|
|
10541
10541
|
name: "HTMLLIElement",
|
|
10542
10542
|
ctor: function HTMLLIElement(doc2, localName, prefix) {
|
|
10543
|
-
|
|
10543
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10544
10544
|
},
|
|
10545
10545
|
attributes: {
|
|
10546
10546
|
value: { type: "long", default: 0 },
|
|
@@ -10562,7 +10562,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10562
10562
|
tag: "legend",
|
|
10563
10563
|
name: "HTMLLegendElement",
|
|
10564
10564
|
ctor: function HTMLLegendElement(doc2, localName, prefix) {
|
|
10565
|
-
|
|
10565
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10566
10566
|
},
|
|
10567
10567
|
attributes: {
|
|
10568
10568
|
align: String
|
|
@@ -10572,7 +10572,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10572
10572
|
tag: "link",
|
|
10573
10573
|
name: "HTMLLinkElement",
|
|
10574
10574
|
ctor: function HTMLLinkElement(doc2, localName, prefix) {
|
|
10575
|
-
|
|
10575
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10576
10576
|
},
|
|
10577
10577
|
attributes: {
|
|
10578
10578
|
href: URL2,
|
|
@@ -10595,7 +10595,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10595
10595
|
tag: "map",
|
|
10596
10596
|
name: "HTMLMapElement",
|
|
10597
10597
|
ctor: function HTMLMapElement(doc2, localName, prefix) {
|
|
10598
|
-
|
|
10598
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10599
10599
|
},
|
|
10600
10600
|
attributes: {
|
|
10601
10601
|
name: String
|
|
@@ -10605,7 +10605,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10605
10605
|
tag: "menu",
|
|
10606
10606
|
name: "HTMLMenuElement",
|
|
10607
10607
|
ctor: function HTMLMenuElement(doc2, localName, prefix) {
|
|
10608
|
-
|
|
10608
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10609
10609
|
},
|
|
10610
10610
|
attributes: {
|
|
10611
10611
|
type: { type: ["context", "popup", "toolbar"], missing: "toolbar" },
|
|
@@ -10617,7 +10617,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10617
10617
|
tag: "meta",
|
|
10618
10618
|
name: "HTMLMetaElement",
|
|
10619
10619
|
ctor: function HTMLMetaElement(doc2, localName, prefix) {
|
|
10620
|
-
|
|
10620
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10621
10621
|
},
|
|
10622
10622
|
attributes: {
|
|
10623
10623
|
name: String,
|
|
@@ -10638,7 +10638,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10638
10638
|
tags: ["ins", "del"],
|
|
10639
10639
|
name: "HTMLModElement",
|
|
10640
10640
|
ctor: function HTMLModElement(doc2, localName, prefix) {
|
|
10641
|
-
|
|
10641
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10642
10642
|
},
|
|
10643
10643
|
attributes: {
|
|
10644
10644
|
cite: URL2,
|
|
@@ -10649,7 +10649,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10649
10649
|
tag: "ol",
|
|
10650
10650
|
name: "HTMLOListElement",
|
|
10651
10651
|
ctor: function HTMLOListElement(doc2, localName, prefix) {
|
|
10652
|
-
|
|
10652
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10653
10653
|
},
|
|
10654
10654
|
props: {
|
|
10655
10655
|
_numitems: { get: function() {
|
|
@@ -10707,7 +10707,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10707
10707
|
tag: "optgroup",
|
|
10708
10708
|
name: "HTMLOptGroupElement",
|
|
10709
10709
|
ctor: function HTMLOptGroupElement(doc2, localName, prefix) {
|
|
10710
|
-
|
|
10710
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10711
10711
|
},
|
|
10712
10712
|
attributes: {
|
|
10713
10713
|
disabled: Boolean,
|
|
@@ -10718,7 +10718,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10718
10718
|
tag: "option",
|
|
10719
10719
|
name: "HTMLOptionElement",
|
|
10720
10720
|
ctor: function HTMLOptionElement(doc2, localName, prefix) {
|
|
10721
|
-
|
|
10721
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10722
10722
|
},
|
|
10723
10723
|
props: {
|
|
10724
10724
|
form: { get: function() {
|
|
@@ -10767,7 +10767,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10767
10767
|
tag: "p",
|
|
10768
10768
|
name: "HTMLParagraphElement",
|
|
10769
10769
|
ctor: function HTMLParagraphElement(doc2, localName, prefix) {
|
|
10770
|
-
|
|
10770
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10771
10771
|
},
|
|
10772
10772
|
attributes: {
|
|
10773
10773
|
align: String
|
|
@@ -10777,7 +10777,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10777
10777
|
tag: "param",
|
|
10778
10778
|
name: "HTMLParamElement",
|
|
10779
10779
|
ctor: function HTMLParamElement(doc2, localName, prefix) {
|
|
10780
|
-
|
|
10780
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10781
10781
|
},
|
|
10782
10782
|
attributes: {
|
|
10783
10783
|
name: String,
|
|
@@ -10790,7 +10790,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10790
10790
|
tags: ["pre", "listing", "xmp"],
|
|
10791
10791
|
name: "HTMLPreElement",
|
|
10792
10792
|
ctor: function HTMLPreElement(doc2, localName, prefix) {
|
|
10793
|
-
|
|
10793
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10794
10794
|
},
|
|
10795
10795
|
attributes: {
|
|
10796
10796
|
width: { type: "long", default: 0 }
|
|
@@ -10811,7 +10811,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10811
10811
|
tags: ["q", "blockquote"],
|
|
10812
10812
|
name: "HTMLQuoteElement",
|
|
10813
10813
|
ctor: function HTMLQuoteElement(doc2, localName, prefix) {
|
|
10814
|
-
|
|
10814
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10815
10815
|
},
|
|
10816
10816
|
attributes: {
|
|
10817
10817
|
cite: URL2
|
|
@@ -10821,7 +10821,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10821
10821
|
tag: "script",
|
|
10822
10822
|
name: "HTMLScriptElement",
|
|
10823
10823
|
ctor: function HTMLScriptElement(doc2, localName, prefix) {
|
|
10824
|
-
|
|
10824
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10825
10825
|
},
|
|
10826
10826
|
props: {
|
|
10827
10827
|
text: {
|
|
@@ -10881,14 +10881,14 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10881
10881
|
tag: "span",
|
|
10882
10882
|
name: "HTMLSpanElement",
|
|
10883
10883
|
ctor: function HTMLSpanElement(doc2, localName, prefix) {
|
|
10884
|
-
|
|
10884
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10885
10885
|
}
|
|
10886
10886
|
});
|
|
10887
10887
|
define2({
|
|
10888
10888
|
tag: "style",
|
|
10889
10889
|
name: "HTMLStyleElement",
|
|
10890
10890
|
ctor: function HTMLStyleElement(doc2, localName, prefix) {
|
|
10891
|
-
|
|
10891
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10892
10892
|
},
|
|
10893
10893
|
attributes: {
|
|
10894
10894
|
media: String,
|
|
@@ -10900,7 +10900,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10900
10900
|
tag: "caption",
|
|
10901
10901
|
name: "HTMLTableCaptionElement",
|
|
10902
10902
|
ctor: function HTMLTableCaptionElement(doc2, localName, prefix) {
|
|
10903
|
-
|
|
10903
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10904
10904
|
},
|
|
10905
10905
|
attributes: {
|
|
10906
10906
|
align: String
|
|
@@ -10909,7 +10909,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10909
10909
|
define2({
|
|
10910
10910
|
name: "HTMLTableCellElement",
|
|
10911
10911
|
ctor: function HTMLTableCellElement(doc2, localName, prefix) {
|
|
10912
|
-
|
|
10912
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10913
10913
|
},
|
|
10914
10914
|
attributes: {
|
|
10915
10915
|
colSpan: { type: "unsigned long", default: 1 },
|
|
@@ -10931,7 +10931,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10931
10931
|
tags: ["col", "colgroup"],
|
|
10932
10932
|
name: "HTMLTableColElement",
|
|
10933
10933
|
ctor: function HTMLTableColElement(doc2, localName, prefix) {
|
|
10934
|
-
|
|
10934
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10935
10935
|
},
|
|
10936
10936
|
attributes: {
|
|
10937
10937
|
span: { type: "limited unsigned long with fallback", default: 1, min: 1 },
|
|
@@ -10946,7 +10946,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10946
10946
|
tag: "table",
|
|
10947
10947
|
name: "HTMLTableElement",
|
|
10948
10948
|
ctor: function HTMLTableElement(doc2, localName, prefix) {
|
|
10949
|
-
|
|
10949
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10950
10950
|
},
|
|
10951
10951
|
props: {
|
|
10952
10952
|
rows: { get: function() {
|
|
@@ -10969,7 +10969,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10969
10969
|
tag: "template",
|
|
10970
10970
|
name: "HTMLTemplateElement",
|
|
10971
10971
|
ctor: function HTMLTemplateElement(doc2, localName, prefix) {
|
|
10972
|
-
|
|
10972
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10973
10973
|
this._contentFragment = doc2._templateDoc.createDocumentFragment();
|
|
10974
10974
|
},
|
|
10975
10975
|
props: {
|
|
@@ -10985,7 +10985,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
10985
10985
|
tag: "tr",
|
|
10986
10986
|
name: "HTMLTableRowElement",
|
|
10987
10987
|
ctor: function HTMLTableRowElement(doc2, localName, prefix) {
|
|
10988
|
-
|
|
10988
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
10989
10989
|
},
|
|
10990
10990
|
props: {
|
|
10991
10991
|
cells: { get: function() {
|
|
@@ -11004,7 +11004,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
11004
11004
|
tags: ["thead", "tfoot", "tbody"],
|
|
11005
11005
|
name: "HTMLTableSectionElement",
|
|
11006
11006
|
ctor: function HTMLTableSectionElement(doc2, localName, prefix) {
|
|
11007
|
-
|
|
11007
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
11008
11008
|
},
|
|
11009
11009
|
props: {
|
|
11010
11010
|
rows: { get: function() {
|
|
@@ -11070,7 +11070,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
11070
11070
|
tag: "time",
|
|
11071
11071
|
name: "HTMLTimeElement",
|
|
11072
11072
|
ctor: function HTMLTimeElement(doc2, localName, prefix) {
|
|
11073
|
-
|
|
11073
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
11074
11074
|
},
|
|
11075
11075
|
attributes: {
|
|
11076
11076
|
dateTime: String,
|
|
@@ -11081,7 +11081,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
11081
11081
|
tag: "title",
|
|
11082
11082
|
name: "HTMLTitleElement",
|
|
11083
11083
|
ctor: function HTMLTitleElement(doc2, localName, prefix) {
|
|
11084
|
-
|
|
11084
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
11085
11085
|
},
|
|
11086
11086
|
props: {
|
|
11087
11087
|
text: { get: function() {
|
|
@@ -11093,7 +11093,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
11093
11093
|
tag: "ul",
|
|
11094
11094
|
name: "HTMLUListElement",
|
|
11095
11095
|
ctor: function HTMLUListElement(doc2, localName, prefix) {
|
|
11096
|
-
|
|
11096
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
11097
11097
|
},
|
|
11098
11098
|
attributes: {
|
|
11099
11099
|
type: String,
|
|
@@ -11103,7 +11103,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
11103
11103
|
define2({
|
|
11104
11104
|
name: "HTMLMediaElement",
|
|
11105
11105
|
ctor: function HTMLMediaElement(doc2, localName, prefix) {
|
|
11106
|
-
|
|
11106
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
11107
11107
|
},
|
|
11108
11108
|
attributes: {
|
|
11109
11109
|
src: URL2,
|
|
@@ -11157,21 +11157,21 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
11157
11157
|
tag: "frameset",
|
|
11158
11158
|
name: "HTMLFrameSetElement",
|
|
11159
11159
|
ctor: function HTMLFrameSetElement(doc2, localName, prefix) {
|
|
11160
|
-
|
|
11160
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
11161
11161
|
}
|
|
11162
11162
|
});
|
|
11163
11163
|
define2({
|
|
11164
11164
|
tag: "frame",
|
|
11165
11165
|
name: "HTMLFrameElement",
|
|
11166
11166
|
ctor: function HTMLFrameElement(doc2, localName, prefix) {
|
|
11167
|
-
|
|
11167
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
11168
11168
|
}
|
|
11169
11169
|
});
|
|
11170
11170
|
define2({
|
|
11171
11171
|
tag: "canvas",
|
|
11172
11172
|
name: "HTMLCanvasElement",
|
|
11173
11173
|
ctor: function HTMLCanvasElement(doc2, localName, prefix) {
|
|
11174
|
-
|
|
11174
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
11175
11175
|
},
|
|
11176
11176
|
props: {
|
|
11177
11177
|
getContext: { value: utils.nyi },
|
|
@@ -11190,7 +11190,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
11190
11190
|
tag: "dialog",
|
|
11191
11191
|
name: "HTMLDialogElement",
|
|
11192
11192
|
ctor: function HTMLDialogElement(doc2, localName, prefix) {
|
|
11193
|
-
|
|
11193
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
11194
11194
|
},
|
|
11195
11195
|
props: {
|
|
11196
11196
|
show: { value: utils.nyi },
|
|
@@ -11206,7 +11206,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
11206
11206
|
tag: "menuitem",
|
|
11207
11207
|
name: "HTMLMenuItemElement",
|
|
11208
11208
|
ctor: function HTMLMenuItemElement(doc2, localName, prefix) {
|
|
11209
|
-
|
|
11209
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
11210
11210
|
},
|
|
11211
11211
|
props: {
|
|
11212
11212
|
_label: {
|
|
@@ -11245,7 +11245,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
11245
11245
|
tag: "source",
|
|
11246
11246
|
name: "HTMLSourceElement",
|
|
11247
11247
|
ctor: function HTMLSourceElement(doc2, localName, prefix) {
|
|
11248
|
-
|
|
11248
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
11249
11249
|
},
|
|
11250
11250
|
attributes: {
|
|
11251
11251
|
srcset: String,
|
|
@@ -11261,7 +11261,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
11261
11261
|
tag: "track",
|
|
11262
11262
|
name: "HTMLTrackElement",
|
|
11263
11263
|
ctor: function HTMLTrackElement(doc2, localName, prefix) {
|
|
11264
|
-
|
|
11264
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
11265
11265
|
},
|
|
11266
11266
|
attributes: {
|
|
11267
11267
|
src: URL2,
|
|
@@ -11291,7 +11291,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
11291
11291
|
tag: "font",
|
|
11292
11292
|
name: "HTMLFontElement",
|
|
11293
11293
|
ctor: function HTMLFontElement(doc2, localName, prefix) {
|
|
11294
|
-
|
|
11294
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
11295
11295
|
},
|
|
11296
11296
|
attributes: {
|
|
11297
11297
|
color: { type: String, treatNullAsEmptyString: true },
|
|
@@ -11303,7 +11303,7 @@ var require_htmlelts = __commonJS((exports) => {
|
|
|
11303
11303
|
tag: "dir",
|
|
11304
11304
|
name: "HTMLDirectoryElement",
|
|
11305
11305
|
ctor: function HTMLDirectoryElement(doc2, localName, prefix) {
|
|
11306
|
-
|
|
11306
|
+
HTMLElement2.call(this, doc2, localName, prefix);
|
|
11307
11307
|
},
|
|
11308
11308
|
attributes: {
|
|
11309
11309
|
compact: Boolean
|
|
@@ -116824,7 +116824,7 @@ var import_picocolors6 = __toESM(require_picocolors(), 1);
|
|
|
116824
116824
|
// package.json
|
|
116825
116825
|
var package_default = {
|
|
116826
116826
|
name: "@vk007/autocli",
|
|
116827
|
-
version: "0.1.
|
|
116827
|
+
version: "0.1.1",
|
|
116828
116828
|
description: "Terminal automation toolkit for developers and AI agents across LLMs, social platforms, developer tools, editors, data tools, and public utilities.",
|
|
116829
116829
|
type: "module",
|
|
116830
116830
|
license: "MIT",
|
|
@@ -134052,8 +134052,10 @@ var PROVIDER_OVERRIDES = {
|
|
|
134052
134052
|
},
|
|
134053
134053
|
grok: {
|
|
134054
134054
|
browserLogin: "supported",
|
|
134055
|
+
browserFallback: "supported",
|
|
134055
134056
|
stability: "partial",
|
|
134056
|
-
asyncJobs: "supported"
|
|
134057
|
+
asyncJobs: "supported",
|
|
134058
|
+
notes: ["AutoCLI can fall back to an in-browser Grok request path when the browserless endpoint is blocked."]
|
|
134057
134059
|
},
|
|
134058
134060
|
mistral: {
|
|
134059
134061
|
browserLogin: "supported",
|
|
@@ -175806,6 +175808,7 @@ import { setTimeout as delay } from "node:timers/promises";
|
|
|
175806
175808
|
import { ModuleClient, SessionClient } from "tlsclientwrapper";
|
|
175807
175809
|
init_errors();
|
|
175808
175810
|
var GROK_HOME_URL = "https://grok.com/";
|
|
175811
|
+
var GROK_IMAGINE_URL = "https://grok.com/imagine";
|
|
175809
175812
|
var GROK_CREATE_CONVERSATION_URL = "https://grok.com/rest/app-chat/conversations/new";
|
|
175810
175813
|
var GROK_MEDIA_POST_URL = "https://grok.com/rest/media/post/get";
|
|
175811
175814
|
var GROK_DEFAULT_MODEL = "grok-3";
|
|
@@ -175815,7 +175818,7 @@ var GROK_VIDEO_POLL_INTERVAL_MS = 3000;
|
|
|
175815
175818
|
var GROK_USER_AGENT = "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/146.0.0.0 Safari/537.36";
|
|
175816
175819
|
var GROK_ACCEPT_LANGUAGE = "en-US,en;q=0.9";
|
|
175817
175820
|
var GROK_TLS_CLIENT_IDENTIFIER = "chrome_146";
|
|
175818
|
-
var
|
|
175821
|
+
var GROK_CREATE_STATSIG_IDS = [
|
|
175819
175822
|
"d+QJ/pTCbTLFjicYQpdy3LuCpY4dNMm2vOB94F21e7fKEIGnvaC60d/v8N+z8uLj4obNAnIN3hObDZJtfNWdlPS423btdA",
|
|
175820
175823
|
"wDhAC5tgENpWVsYXN0kQnXXQ+Xtq38rZRVppk9Uy1xhmWpIdU7q6y4f6HEU3wXpLl9N0tcWvwAioklw42J27RNEuP5ssww"
|
|
175821
175824
|
];
|
|
@@ -175899,6 +175902,9 @@ class GrokService {
|
|
|
175899
175902
|
}
|
|
175900
175903
|
}
|
|
175901
175904
|
async executeText(client, input) {
|
|
175905
|
+
if (input.browser) {
|
|
175906
|
+
return this.executeTextInBrowser(client, input);
|
|
175907
|
+
}
|
|
175902
175908
|
try {
|
|
175903
175909
|
const parsed = await withGrokTlsSession(client.jar, async (session) => parseGrokConversationStream(await postGrokCreateConversation(session, client.jar, buildGrokCreatePayload(input.prompt, input.model))));
|
|
175904
175910
|
if (!parsed.outputText) {
|
|
@@ -175918,47 +175924,15 @@ class GrokService {
|
|
|
175918
175924
|
followUpSuggestions: parsed.followUpSuggestions
|
|
175919
175925
|
};
|
|
175920
175926
|
} catch (error49) {
|
|
175921
|
-
|
|
175927
|
+
const mapped = mapGrokError(error49, "Failed to complete the Grok prompt.");
|
|
175928
|
+
if (mapped.code === "GROK_ANTI_BOT_BLOCKED") {
|
|
175929
|
+
return this.executeTextInBrowser(client, input);
|
|
175930
|
+
}
|
|
175931
|
+
throw mapped;
|
|
175922
175932
|
}
|
|
175923
175933
|
}
|
|
175924
175934
|
async executeImage(client, input) {
|
|
175925
|
-
|
|
175926
|
-
return await withGrokTlsSession(client.jar, async (session) => {
|
|
175927
|
-
const parsed = parseGrokConversationStream(await postGrokCreateConversation(session, client.jar, buildGrokImageGenerationPayload(input.prompt, input.model)));
|
|
175928
|
-
const imageAssets = selectFinalGrokImageAssets(parsed.imageAssets);
|
|
175929
|
-
if (imageAssets.length === 0) {
|
|
175930
|
-
throw new AutoCliError("GROK_IMAGE_GENERATION_FAILED", "Grok did not return any generated images.", {
|
|
175931
|
-
details: {
|
|
175932
|
-
conversationId: parsed.conversationId,
|
|
175933
|
-
responseId: parsed.responseId,
|
|
175934
|
-
outputText: parsed.outputText
|
|
175935
|
-
}
|
|
175936
|
-
});
|
|
175937
|
-
}
|
|
175938
|
-
const downloads = await Promise.all(imageAssets.map(async (asset, index) => {
|
|
175939
|
-
const outputUrl = resolveGrokAssetUrl(asset.assetPath);
|
|
175940
|
-
const outputPath = await downloadGrokAsset(session, client.jar, outputUrl, "images", {
|
|
175941
|
-
prefix: `${parsed.conversationId ?? "grok"}-${asset.imageUuid ?? String(index + 1)}`
|
|
175942
|
-
});
|
|
175943
|
-
return {
|
|
175944
|
-
outputPath,
|
|
175945
|
-
outputUrl
|
|
175946
|
-
};
|
|
175947
|
-
}));
|
|
175948
|
-
return {
|
|
175949
|
-
outputText: parsed.outputText && !parsed.outputText.includes("<grok:render") ? parsed.outputText : `Generated ${downloads.length} Grok image${downloads.length === 1 ? "" : "s"}.`,
|
|
175950
|
-
conversationId: parsed.conversationId,
|
|
175951
|
-
responseId: parsed.responseId,
|
|
175952
|
-
model: parsed.model ?? resolveGrokModel(input.model),
|
|
175953
|
-
followUpSuggestions: parsed.followUpSuggestions,
|
|
175954
|
-
outputPaths: downloads.map((download) => download.outputPath),
|
|
175955
|
-
outputUrls: downloads.map((download) => download.outputUrl),
|
|
175956
|
-
imageUuid: imageAssets[0]?.imageUuid
|
|
175957
|
-
};
|
|
175958
|
-
});
|
|
175959
|
-
} catch (error49) {
|
|
175960
|
-
throw mapGrokError(error49, "Failed to generate the Grok image.");
|
|
175961
|
-
}
|
|
175935
|
+
return this.executeImageInBrowser(client, input);
|
|
175962
175936
|
}
|
|
175963
175937
|
async downloadImages(client, input) {
|
|
175964
175938
|
try {
|
|
@@ -175985,60 +175959,7 @@ class GrokService {
|
|
|
175985
175959
|
}
|
|
175986
175960
|
}
|
|
175987
175961
|
async executeVideo(client, input) {
|
|
175988
|
-
|
|
175989
|
-
return await withGrokTlsSession(client.jar, async (session) => {
|
|
175990
|
-
const imageParsed = parseGrokConversationStream(await postGrokCreateConversation(session, client.jar, buildGrokImageGenerationPayload(input.prompt, input.model)));
|
|
175991
|
-
const seedImage = selectPrimaryGrokImageAsset(imageParsed.imageAssets);
|
|
175992
|
-
if (!seedImage?.imageUuid) {
|
|
175993
|
-
throw new AutoCliError("GROK_VIDEO_SEED_IMAGE_FAILED", "Grok did not return a usable seed image for video generation.", {
|
|
175994
|
-
details: {
|
|
175995
|
-
conversationId: imageParsed.conversationId,
|
|
175996
|
-
responseId: imageParsed.responseId
|
|
175997
|
-
}
|
|
175998
|
-
});
|
|
175999
|
-
}
|
|
176000
|
-
const seedImageUrl = resolveGrokAssetUrl(seedImage.assetPath);
|
|
176001
|
-
const seedImagePath = await downloadGrokAsset(session, client.jar, seedImageUrl, "images", {
|
|
176002
|
-
prefix: `${imageParsed.conversationId ?? "grok"}-seed-${seedImage.imageUuid}`
|
|
176003
|
-
});
|
|
176004
|
-
const videoParsed = parseGrokConversationStream(await postGrokCreateConversation(session, client.jar, buildGrokVideoPayload({
|
|
176005
|
-
prompt: input.prompt,
|
|
176006
|
-
model: input.model,
|
|
176007
|
-
imageUuid: seedImage.imageUuid,
|
|
176008
|
-
imagePath: seedImage.assetPath
|
|
176009
|
-
}), {
|
|
176010
|
-
timeoutSeconds: 150
|
|
176011
|
-
}));
|
|
176012
|
-
const latestVideoUpdate = selectLatestGrokVideoUpdate(videoParsed.videoUpdates);
|
|
176013
|
-
const outputUrl = (latestVideoUpdate?.videoUrl ? resolveGrokAssetUrl(latestVideoUpdate.videoUrl) : undefined) ?? await pollForGrokVideoUrl(session, client.jar, {
|
|
176014
|
-
conversationId: videoParsed.conversationId,
|
|
176015
|
-
videoId: latestVideoUpdate?.videoId
|
|
176016
|
-
});
|
|
176017
|
-
const outputPaths = outputUrl ? [
|
|
176018
|
-
await downloadGrokAsset(session, client.jar, outputUrl, "videos", {
|
|
176019
|
-
prefix: `${videoParsed.conversationId ?? "grok"}-${latestVideoUpdate?.videoId ?? "video"}`
|
|
176020
|
-
})
|
|
176021
|
-
] : [];
|
|
176022
|
-
const status = outputUrl ? "completed" : "processing";
|
|
176023
|
-
return {
|
|
176024
|
-
outputText: videoParsed.outputText || (status === "completed" ? "Generated a Grok video." : "Grok accepted the video generation job, but the final asset URL is still pending."),
|
|
176025
|
-
conversationId: videoParsed.conversationId,
|
|
176026
|
-
responseId: videoParsed.responseId,
|
|
176027
|
-
model: videoParsed.model ?? latestVideoUpdate?.modelName ?? resolveGrokModel(input.model),
|
|
176028
|
-
followUpSuggestions: dedupeValues([...imageParsed.followUpSuggestions, ...videoParsed.followUpSuggestions]),
|
|
176029
|
-
status,
|
|
176030
|
-
outputUrl,
|
|
176031
|
-
outputUrls: outputUrl ? [outputUrl] : [],
|
|
176032
|
-
outputPaths,
|
|
176033
|
-
videoId: latestVideoUpdate?.videoId,
|
|
176034
|
-
progress: latestVideoUpdate?.progress,
|
|
176035
|
-
seedImageUrl,
|
|
176036
|
-
seedImagePath
|
|
176037
|
-
};
|
|
176038
|
-
});
|
|
176039
|
-
} catch (error49) {
|
|
176040
|
-
throw mapGrokError(error49, "Failed to generate the Grok video.");
|
|
176041
|
-
}
|
|
175962
|
+
return this.executeVideoInBrowser(client, input);
|
|
176042
175963
|
}
|
|
176043
175964
|
async getVideoStatus(client, input) {
|
|
176044
175965
|
try {
|
|
@@ -176182,6 +176103,297 @@ class GrokService {
|
|
|
176182
176103
|
}
|
|
176183
176104
|
return response.data;
|
|
176184
176105
|
}
|
|
176106
|
+
async executeTextInBrowser(client, input) {
|
|
176107
|
+
const parsed = await this.executeConversationInBrowser(client, {
|
|
176108
|
+
prompt: input.prompt,
|
|
176109
|
+
timeoutSeconds: input.browserTimeoutSeconds
|
|
176110
|
+
});
|
|
176111
|
+
if (!parsed.outputText) {
|
|
176112
|
+
throw new AutoCliError("GROK_EMPTY_RESPONSE", "Grok returned an empty response.", {
|
|
176113
|
+
details: {
|
|
176114
|
+
conversationId: parsed.conversationId,
|
|
176115
|
+
responseId: parsed.responseId,
|
|
176116
|
+
model: parsed.model ?? resolveGrokModel(input.model)
|
|
176117
|
+
}
|
|
176118
|
+
});
|
|
176119
|
+
}
|
|
176120
|
+
return {
|
|
176121
|
+
outputText: parsed.outputText,
|
|
176122
|
+
conversationId: parsed.conversationId,
|
|
176123
|
+
responseId: parsed.responseId,
|
|
176124
|
+
model: parsed.model ?? resolveGrokModel(input.model),
|
|
176125
|
+
followUpSuggestions: parsed.followUpSuggestions
|
|
176126
|
+
};
|
|
176127
|
+
}
|
|
176128
|
+
async executeImageInBrowser(client, input) {
|
|
176129
|
+
const generated = await this.executeImagineInBrowser(client, {
|
|
176130
|
+
prompt: input.prompt,
|
|
176131
|
+
mode: "image",
|
|
176132
|
+
timeoutSeconds: input.browserTimeoutSeconds
|
|
176133
|
+
});
|
|
176134
|
+
const outputUrls = resolveBrowserImagineImageUrls(generated);
|
|
176135
|
+
if (outputUrls.length === 0) {
|
|
176136
|
+
throw new AutoCliError("GROK_IMAGE_GENERATION_FAILED", "Grok did not return any generated images.", {
|
|
176137
|
+
details: {
|
|
176138
|
+
outputText: generated.parsed?.outputText,
|
|
176139
|
+
prompt: input.prompt
|
|
176140
|
+
}
|
|
176141
|
+
});
|
|
176142
|
+
}
|
|
176143
|
+
const downloads = await Promise.all(outputUrls.map(async (assetUrl, index) => {
|
|
176144
|
+
const outputPath = isDataUri(assetUrl) ? await writeGrokBrowserAsset(assetUrl, "images", {
|
|
176145
|
+
prefix: `${generated.parsed?.conversationId ?? "grok-image"}-${String(index + 1)}`
|
|
176146
|
+
}) : await downloadBrowserAccessibleAsset(client, assetUrl, "images", {
|
|
176147
|
+
prefix: `${generated.parsed?.conversationId ?? "grok-image"}-${String(index + 1)}`,
|
|
176148
|
+
referer: GROK_IMAGINE_URL
|
|
176149
|
+
});
|
|
176150
|
+
return {
|
|
176151
|
+
outputPath,
|
|
176152
|
+
outputUrl: assetUrl
|
|
176153
|
+
};
|
|
176154
|
+
}));
|
|
176155
|
+
const exposedOutputUrls = downloads.map((download) => download.outputUrl).filter((outputUrl) => !isDataUri(outputUrl));
|
|
176156
|
+
return {
|
|
176157
|
+
outputText: generated.parsed?.outputText && !generated.parsed.outputText.includes("<grok:render") ? generated.parsed.outputText : `Generated ${downloads.length} Grok image${downloads.length === 1 ? "" : "s"}.`,
|
|
176158
|
+
conversationId: generated.conversationId ?? generated.parsed?.conversationId,
|
|
176159
|
+
responseId: generated.parsed?.responseId,
|
|
176160
|
+
model: generated.parsed?.model ?? resolveGrokModel(input.model),
|
|
176161
|
+
followUpSuggestions: generated.parsed?.followUpSuggestions ?? [],
|
|
176162
|
+
outputPaths: downloads.map((download) => download.outputPath),
|
|
176163
|
+
outputUrls: exposedOutputUrls,
|
|
176164
|
+
imageUuid: generated.parsed?.imageAssets[0]?.imageUuid
|
|
176165
|
+
};
|
|
176166
|
+
}
|
|
176167
|
+
async executeVideoInBrowser(client, input) {
|
|
176168
|
+
const generated = await this.executeImagineInBrowser(client, {
|
|
176169
|
+
prompt: input.prompt,
|
|
176170
|
+
mode: "video",
|
|
176171
|
+
timeoutSeconds: input.browserTimeoutSeconds ? Math.max(input.browserTimeoutSeconds, 180) : 180
|
|
176172
|
+
});
|
|
176173
|
+
const latestVideoUpdate = selectLatestGrokVideoUpdate(generated.parsed?.videoUpdates ?? []);
|
|
176174
|
+
const outputUrl = resolveBrowserImagineVideoUrl(generated, latestVideoUpdate);
|
|
176175
|
+
const outputPaths = outputUrl ? [
|
|
176176
|
+
await downloadBrowserAccessibleAsset(client, outputUrl, "videos", {
|
|
176177
|
+
prefix: `${generated.parsed?.conversationId ?? "grok-video"}-video`,
|
|
176178
|
+
referer: GROK_IMAGINE_URL
|
|
176179
|
+
})
|
|
176180
|
+
] : [];
|
|
176181
|
+
const status = outputUrl ? "completed" : "processing";
|
|
176182
|
+
return {
|
|
176183
|
+
outputText: status === "completed" ? "Generated a Grok video." : "Grok accepted the video generation job, but the final asset URL is still pending.",
|
|
176184
|
+
conversationId: generated.conversationId ?? generated.parsed?.conversationId,
|
|
176185
|
+
responseId: generated.parsed?.responseId,
|
|
176186
|
+
model: generated.parsed?.model ?? latestVideoUpdate?.modelName ?? resolveGrokModel(input.model),
|
|
176187
|
+
followUpSuggestions: generated.parsed?.followUpSuggestions ?? [],
|
|
176188
|
+
status,
|
|
176189
|
+
outputUrl,
|
|
176190
|
+
outputUrls: outputUrl ? [outputUrl] : [],
|
|
176191
|
+
outputPaths,
|
|
176192
|
+
videoId: latestVideoUpdate?.videoId,
|
|
176193
|
+
progress: latestVideoUpdate?.progress
|
|
176194
|
+
};
|
|
176195
|
+
}
|
|
176196
|
+
async executeConversationInBrowser(client, input) {
|
|
176197
|
+
const initialCookies = (await client.jar.getCookies(GROK_HOME_URL)).map((cookie) => cookie.toJSON());
|
|
176198
|
+
const result = await runBrowserActionPlan({
|
|
176199
|
+
targetUrl: GROK_HOME_URL,
|
|
176200
|
+
timeoutSeconds: input.timeoutSeconds ?? 180,
|
|
176201
|
+
initialCookies,
|
|
176202
|
+
headless: true,
|
|
176203
|
+
userAgent: GROK_USER_AGENT,
|
|
176204
|
+
locale: "en-US",
|
|
176205
|
+
steps: [
|
|
176206
|
+
{
|
|
176207
|
+
source: "headless",
|
|
176208
|
+
shouldContinueOnError: (error49) => shouldRetryGrokBrowserAction(error49)
|
|
176209
|
+
},
|
|
176210
|
+
{
|
|
176211
|
+
source: "shared",
|
|
176212
|
+
announceLabel: `Opening shared AutoCLI browser profile for Grok: ${GROK_HOME_URL}`
|
|
176213
|
+
}
|
|
176214
|
+
],
|
|
176215
|
+
action: async (page) => {
|
|
176216
|
+
await this.ensureBrowserAuthenticated(page);
|
|
176217
|
+
const stream = await this.submitChatPromptInBrowser(page, input.prompt, input.timeoutSeconds);
|
|
176218
|
+
return {
|
|
176219
|
+
stream,
|
|
176220
|
+
cookies: await page.context().cookies()
|
|
176221
|
+
};
|
|
176222
|
+
}
|
|
176223
|
+
});
|
|
176224
|
+
await syncBrowserCookiesToJar(client.jar, result.cookies);
|
|
176225
|
+
return parseGrokConversationStream(result.stream);
|
|
176226
|
+
}
|
|
176227
|
+
async executeImagineInBrowser(client, input) {
|
|
176228
|
+
const initialCookies = (await client.jar.getCookies(GROK_HOME_URL)).map((cookie) => cookie.toJSON());
|
|
176229
|
+
const result = await runBrowserActionPlan({
|
|
176230
|
+
targetUrl: GROK_IMAGINE_URL,
|
|
176231
|
+
timeoutSeconds: input.timeoutSeconds ?? (input.mode === "video" ? 180 : 120),
|
|
176232
|
+
initialCookies,
|
|
176233
|
+
headless: true,
|
|
176234
|
+
userAgent: GROK_USER_AGENT,
|
|
176235
|
+
locale: "en-US",
|
|
176236
|
+
steps: [
|
|
176237
|
+
{
|
|
176238
|
+
source: "headless",
|
|
176239
|
+
shouldContinueOnError: (error49) => shouldRetryGrokBrowserAction(error49)
|
|
176240
|
+
},
|
|
176241
|
+
{
|
|
176242
|
+
source: "shared",
|
|
176243
|
+
announceLabel: `Opening shared AutoCLI browser profile for Grok Imagine: ${GROK_IMAGINE_URL}`
|
|
176244
|
+
}
|
|
176245
|
+
],
|
|
176246
|
+
action: async (page) => {
|
|
176247
|
+
await this.ensureBrowserAuthenticated(page);
|
|
176248
|
+
const assetCollector = createGrokGeneratedAssetCollector(page, input.mode);
|
|
176249
|
+
const streamPromise = this.captureBrowserConversationStream(page, Math.min((input.timeoutSeconds ?? (input.mode === "video" ? 180 : 120)) * 1000, 150000)).catch(() => {
|
|
176250
|
+
return;
|
|
176251
|
+
});
|
|
176252
|
+
try {
|
|
176253
|
+
const assetUrls = await this.submitImaginePromptInBrowser(page, input.prompt, input.mode, input.timeoutSeconds);
|
|
176254
|
+
return {
|
|
176255
|
+
assetUrls,
|
|
176256
|
+
collectedAssetUrls: assetCollector.stop(),
|
|
176257
|
+
pageUrl: page.url(),
|
|
176258
|
+
stream: await waitForOptionalBrowserStream(streamPromise, input.timeoutSeconds ? input.timeoutSeconds * 1000 : input.mode === "video" ? 12000 : 6000),
|
|
176259
|
+
cookies: await page.context().cookies()
|
|
176260
|
+
};
|
|
176261
|
+
} finally {
|
|
176262
|
+
assetCollector.stop();
|
|
176263
|
+
}
|
|
176264
|
+
}
|
|
176265
|
+
});
|
|
176266
|
+
await syncBrowserCookiesToJar(client.jar, result.cookies);
|
|
176267
|
+
const parsed = result.stream ? parseGrokConversationStream(result.stream) : undefined;
|
|
176268
|
+
const derivedConversationId = extractGrokImaginePostId(result.pageUrl);
|
|
176269
|
+
return {
|
|
176270
|
+
assetUrls: dedupeValues([...result.collectedAssetUrls, ...result.assetUrls]),
|
|
176271
|
+
conversationId: derivedConversationId ?? parsed?.conversationId,
|
|
176272
|
+
parsed
|
|
176273
|
+
};
|
|
176274
|
+
}
|
|
176275
|
+
async ensureBrowserAuthenticated(page) {
|
|
176276
|
+
await page.waitForLoadState("domcontentloaded");
|
|
176277
|
+
await page.waitForTimeout(1000);
|
|
176278
|
+
const url2 = page.url().toLowerCase();
|
|
176279
|
+
if (url2.includes("/login") || url2.includes("/sign-in")) {
|
|
176280
|
+
throw new AutoCliError("GROK_BROWSER_NOT_LOGGED_IN", "The browser session is not logged into Grok. Run `autocli llm grok login --browser` first.");
|
|
176281
|
+
}
|
|
176282
|
+
const bodyText = normalizeWhitespace(await page.locator("body").innerText().catch(() => ""));
|
|
176283
|
+
if (!bodyText) {
|
|
176284
|
+
return;
|
|
176285
|
+
}
|
|
176286
|
+
const blockedPatterns = [
|
|
176287
|
+
/sign in/i,
|
|
176288
|
+
/log in/i,
|
|
176289
|
+
/access denied/i,
|
|
176290
|
+
/something went wrong/i,
|
|
176291
|
+
/try again later/i,
|
|
176292
|
+
/unusual activity/i
|
|
176293
|
+
];
|
|
176294
|
+
for (const pattern of blockedPatterns) {
|
|
176295
|
+
const match = bodyText.match(pattern);
|
|
176296
|
+
if (match) {
|
|
176297
|
+
if (/sign in|log in/i.test(match[0])) {
|
|
176298
|
+
throw new AutoCliError("GROK_BROWSER_NOT_LOGGED_IN", "The browser session is not logged into Grok. Run `autocli llm grok login --browser` first.");
|
|
176299
|
+
}
|
|
176300
|
+
throw new AutoCliError("GROK_BROWSER_ACTION_FAILED", match[0], {
|
|
176301
|
+
details: {
|
|
176302
|
+
url: page.url()
|
|
176303
|
+
}
|
|
176304
|
+
});
|
|
176305
|
+
}
|
|
176306
|
+
}
|
|
176307
|
+
}
|
|
176308
|
+
async submitChatPromptInBrowser(page, prompt, timeoutSeconds) {
|
|
176309
|
+
const responsePromise = this.captureBrowserConversationStream(page, Math.min((timeoutSeconds ?? 180) * 1000, 90000));
|
|
176310
|
+
await this.fillAndSubmitBrowserComposer(page, prompt, Math.min((timeoutSeconds ?? 180) * 1000, 20000));
|
|
176311
|
+
return responsePromise;
|
|
176312
|
+
}
|
|
176313
|
+
async submitImaginePromptInBrowser(page, prompt, mode, timeoutSeconds) {
|
|
176314
|
+
if (mode === "video") {
|
|
176315
|
+
const videoMode = page.getByRole("radio", { name: "Video", exact: true }).last();
|
|
176316
|
+
await videoMode.waitFor({
|
|
176317
|
+
state: "visible",
|
|
176318
|
+
timeout: 15000
|
|
176319
|
+
});
|
|
176320
|
+
await videoMode.click();
|
|
176321
|
+
await page.waitForTimeout(1000);
|
|
176322
|
+
}
|
|
176323
|
+
const existingAssetUrls = await collectImagineAssetUrls(page, mode);
|
|
176324
|
+
await this.fillAndSubmitBrowserComposer(page, prompt, Math.min((timeoutSeconds ?? (mode === "video" ? 180 : 120)) * 1000, 20000));
|
|
176325
|
+
const timeoutMs = Math.max(30000, (timeoutSeconds ?? (mode === "video" ? 180 : 120)) * 1000);
|
|
176326
|
+
await page.waitForFunction(({ currentMode, previousUrls }) => {
|
|
176327
|
+
const matches = Array.from(document.querySelectorAll(currentMode === "video" ? "video, source" : "img"), (node) => {
|
|
176328
|
+
if (!(node instanceof HTMLElement)) {
|
|
176329
|
+
return "";
|
|
176330
|
+
}
|
|
176331
|
+
const currentSrc = "currentSrc" in node ? String(node.currentSrc || "") : "";
|
|
176332
|
+
const src = currentSrc || node.getAttribute("src") || "";
|
|
176333
|
+
const alt = node.getAttribute("alt") || "";
|
|
176334
|
+
if (!src || previousUrls.includes(src)) {
|
|
176335
|
+
return "";
|
|
176336
|
+
}
|
|
176337
|
+
if (currentMode === "video") {
|
|
176338
|
+
return src.includes("/generated/") || src.includes(".mp4") ? src : "";
|
|
176339
|
+
}
|
|
176340
|
+
const naturalWidth = node instanceof HTMLImageElement ? node.naturalWidth || 0 : 0;
|
|
176341
|
+
const naturalHeight = node instanceof HTMLImageElement ? node.naturalHeight || 0 : 0;
|
|
176342
|
+
const isLargeInlineImage = src.startsWith("data:image/") && (naturalWidth >= 512 || naturalHeight >= 512);
|
|
176343
|
+
const isRemoteGeneratedImage = src.includes("/generated/") && !src.includes("preview_image");
|
|
176344
|
+
const isGeneratedImage = isLargeInlineImage || isRemoteGeneratedImage || alt === "Generated image" && (isLargeInlineImage || isRemoteGeneratedImage);
|
|
176345
|
+
if (!isGeneratedImage)
|
|
176346
|
+
return "";
|
|
176347
|
+
return src;
|
|
176348
|
+
}).filter(Boolean);
|
|
176349
|
+
return matches.length > 0;
|
|
176350
|
+
}, {
|
|
176351
|
+
currentMode: mode,
|
|
176352
|
+
previousUrls: existingAssetUrls
|
|
176353
|
+
}, {
|
|
176354
|
+
timeout: timeoutMs
|
|
176355
|
+
});
|
|
176356
|
+
await page.waitForTimeout(mode === "video" ? 3000 : 3500);
|
|
176357
|
+
const latestAssetUrls = await collectImagineAssetUrls(page, mode);
|
|
176358
|
+
return selectRecentImagineAssetUrls(latestAssetUrls.filter((url2) => !existingAssetUrls.includes(url2)), mode);
|
|
176359
|
+
}
|
|
176360
|
+
async fillAndSubmitBrowserComposer(page, prompt, timeoutMs) {
|
|
176361
|
+
const editor = page.locator('[contenteditable="true"]').first();
|
|
176362
|
+
await editor.waitFor({
|
|
176363
|
+
state: "visible",
|
|
176364
|
+
timeout: timeoutMs
|
|
176365
|
+
});
|
|
176366
|
+
await editor.click();
|
|
176367
|
+
await page.keyboard.press(process.platform === "darwin" ? "Meta+A" : "Control+A").catch(() => {});
|
|
176368
|
+
await page.keyboard.press("Backspace").catch(() => {});
|
|
176369
|
+
await page.keyboard.type(prompt, {
|
|
176370
|
+
delay: 12
|
|
176371
|
+
});
|
|
176372
|
+
const submit = page.locator('button[aria-label="Submit"]').last();
|
|
176373
|
+
await submit.waitFor({
|
|
176374
|
+
state: "visible",
|
|
176375
|
+
timeout: timeoutMs
|
|
176376
|
+
});
|
|
176377
|
+
await page.waitForFunction(() => {
|
|
176378
|
+
const submitButton = Array.from(document.querySelectorAll('button[aria-label="Submit"]')).at(-1);
|
|
176379
|
+
return submitButton instanceof HTMLButtonElement && !submitButton.disabled;
|
|
176380
|
+
}, {
|
|
176381
|
+
timeout: timeoutMs
|
|
176382
|
+
});
|
|
176383
|
+
await submit.click({
|
|
176384
|
+
force: true
|
|
176385
|
+
});
|
|
176386
|
+
}
|
|
176387
|
+
async captureBrowserConversationStream(page, timeoutMs) {
|
|
176388
|
+
const response = await page.waitForResponse((candidate) => candidate.url().includes("/rest/app-chat/conversations/new"), {
|
|
176389
|
+
timeout: timeoutMs
|
|
176390
|
+
});
|
|
176391
|
+
const body = await response.text();
|
|
176392
|
+
if (response.status() !== 200) {
|
|
176393
|
+
throw createGrokRequestError(response.status(), body);
|
|
176394
|
+
}
|
|
176395
|
+
return body;
|
|
176396
|
+
}
|
|
176185
176397
|
}
|
|
176186
176398
|
function inspectGrokHomeHtml(html) {
|
|
176187
176399
|
const subscriptionTierMatch = html.match(/"bestSubscription":"([^"]+)"/u) ?? html.match(/\\"bestSubscription\\":\\"([^"]+)\\"/u);
|
|
@@ -176327,42 +176539,6 @@ function buildGrokCreatePayload(prompt, requestedModel) {
|
|
|
176327
176539
|
enable420: false
|
|
176328
176540
|
};
|
|
176329
176541
|
}
|
|
176330
|
-
function buildGrokImageGenerationPayload(prompt, requestedModel) {
|
|
176331
|
-
return {
|
|
176332
|
-
...buildGrokCreatePayload(`Generate an original image: ${prompt}`.trim(), requestedModel),
|
|
176333
|
-
disableSearch: true
|
|
176334
|
-
};
|
|
176335
|
-
}
|
|
176336
|
-
function buildGrokVideoPayload(input) {
|
|
176337
|
-
return {
|
|
176338
|
-
...buildGrokCreatePayload(`${input.imagePath} ${input.prompt} --mode=normal`.trim(), input.model),
|
|
176339
|
-
temporary: true,
|
|
176340
|
-
fileAttachments: [input.imageUuid],
|
|
176341
|
-
enableImageGeneration: false,
|
|
176342
|
-
enableImageStreaming: false,
|
|
176343
|
-
imageGenerationCount: 0,
|
|
176344
|
-
disableSearch: true,
|
|
176345
|
-
toolOverrides: {
|
|
176346
|
-
...buildBaseToolOverrides(),
|
|
176347
|
-
videoGen: true
|
|
176348
|
-
},
|
|
176349
|
-
responseMetadata: {
|
|
176350
|
-
experiments: {},
|
|
176351
|
-
modelConfigOverride: {
|
|
176352
|
-
modelMap: {
|
|
176353
|
-
videoGenModelConfig: {
|
|
176354
|
-
parentPostId: input.imageUuid,
|
|
176355
|
-
aspectRatio: "16:9",
|
|
176356
|
-
videoLength: 5,
|
|
176357
|
-
isVideoEdit: false,
|
|
176358
|
-
resolutionName: "360p",
|
|
176359
|
-
isReferenceToVideo: false
|
|
176360
|
-
}
|
|
176361
|
-
}
|
|
176362
|
-
}
|
|
176363
|
-
}
|
|
176364
|
-
};
|
|
176365
|
-
}
|
|
176366
176542
|
function buildBaseToolOverrides() {
|
|
176367
176543
|
return {
|
|
176368
176544
|
gmailSearch: false,
|
|
@@ -176503,6 +176679,55 @@ function buildGrokCreateHeaders(statsigId) {
|
|
|
176503
176679
|
"sec-fetch-site": "same-origin"
|
|
176504
176680
|
};
|
|
176505
176681
|
}
|
|
176682
|
+
function shouldRetryGrokBrowserAction(error49) {
|
|
176683
|
+
if (!isAutoCliError(error49)) {
|
|
176684
|
+
return false;
|
|
176685
|
+
}
|
|
176686
|
+
return error49.code === "GROK_ANTI_BOT_BLOCKED" || error49.code === "GROK_BROWSER_ACTION_FAILED" || error49.code === "GROK_BROWSER_NOT_LOGGED_IN";
|
|
176687
|
+
}
|
|
176688
|
+
async function syncBrowserCookiesToJar(jar, cookies) {
|
|
176689
|
+
const browserCookies = Array.isArray(cookies) ? cookies : [];
|
|
176690
|
+
for (const rawCookie of browserCookies) {
|
|
176691
|
+
if (!rawCookie || typeof rawCookie !== "object") {
|
|
176692
|
+
continue;
|
|
176693
|
+
}
|
|
176694
|
+
const value = rawCookie;
|
|
176695
|
+
const cookie = Cookie.fromJSON({
|
|
176696
|
+
key: typeof value.name === "string" ? value.name : "",
|
|
176697
|
+
value: typeof value.value === "string" ? value.value : "",
|
|
176698
|
+
domain: typeof value.domain === "string" ? value.domain : "",
|
|
176699
|
+
path: typeof value.path === "string" ? value.path : "/",
|
|
176700
|
+
secure: typeof value.secure === "boolean" ? value.secure : undefined,
|
|
176701
|
+
httpOnly: typeof value.httpOnly === "boolean" ? value.httpOnly : undefined,
|
|
176702
|
+
sameSite: typeof value.sameSite === "string" ? value.sameSite.toLowerCase() : undefined,
|
|
176703
|
+
expires: typeof value.expires === "number" && Number.isFinite(value.expires) && value.expires > 0 ? new Date(value.expires * 1000).toISOString() : "Infinity"
|
|
176704
|
+
});
|
|
176705
|
+
if (!cookie) {
|
|
176706
|
+
continue;
|
|
176707
|
+
}
|
|
176708
|
+
const protocol = cookie.secure ? "https" : "http";
|
|
176709
|
+
const cookieDomain = typeof cookie.domain === "string" ? cookie.domain : "";
|
|
176710
|
+
const domain2 = cookieDomain.startsWith(".") ? cookieDomain.slice(1) : cookieDomain;
|
|
176711
|
+
if (!domain2) {
|
|
176712
|
+
continue;
|
|
176713
|
+
}
|
|
176714
|
+
await jar.setCookie(cookie, `${protocol}://${domain2}${cookie.path || "/"}`, {
|
|
176715
|
+
ignoreError: true
|
|
176716
|
+
});
|
|
176717
|
+
}
|
|
176718
|
+
}
|
|
176719
|
+
async function waitForOptionalBrowserStream(streamPromise, timeoutMs) {
|
|
176720
|
+
return new Promise((resolve8, reject) => {
|
|
176721
|
+
const timer = setTimeout(() => resolve8(undefined), timeoutMs);
|
|
176722
|
+
streamPromise.then((value) => {
|
|
176723
|
+
clearTimeout(timer);
|
|
176724
|
+
resolve8(value);
|
|
176725
|
+
}, (error49) => {
|
|
176726
|
+
clearTimeout(timer);
|
|
176727
|
+
reject(error49);
|
|
176728
|
+
});
|
|
176729
|
+
});
|
|
176730
|
+
}
|
|
176506
176731
|
async function withGrokTlsSession(jar, action) {
|
|
176507
176732
|
const moduleClient = new ModuleClient;
|
|
176508
176733
|
await moduleClient.open();
|
|
@@ -176530,7 +176755,7 @@ async function withGrokTlsSession(jar, action) {
|
|
|
176530
176755
|
}
|
|
176531
176756
|
async function postGrokCreateConversation(session, jar, body, requestOptions) {
|
|
176532
176757
|
let lastError;
|
|
176533
|
-
for (const statsigId of
|
|
176758
|
+
for (const statsigId of GROK_CREATE_STATSIG_IDS) {
|
|
176534
176759
|
const response = await session.post(GROK_CREATE_CONVERSATION_URL, body, {
|
|
176535
176760
|
headers: buildGrokCreateHeaders(statsigId),
|
|
176536
176761
|
headerOrder: [...GROK_CREATE_HEADER_ORDER],
|
|
@@ -176552,24 +176777,6 @@ async function postGrokCreateConversation(session, jar, body, requestOptions) {
|
|
|
176552
176777
|
}
|
|
176553
176778
|
});
|
|
176554
176779
|
}
|
|
176555
|
-
async function pollForGrokVideoUrl(session, jar, input) {
|
|
176556
|
-
const deadline = Date.now() + GROK_VIDEO_POLL_TIMEOUT_MS;
|
|
176557
|
-
while (Date.now() < deadline) {
|
|
176558
|
-
const candidates = await Promise.all([
|
|
176559
|
-
input.conversationId ? fetchGrokConversationResponses(session, jar, input.conversationId) : Promise.resolve(undefined),
|
|
176560
|
-
input.conversationId ? fetchGrokConversationV2(session, jar, input.conversationId) : Promise.resolve(undefined),
|
|
176561
|
-
input.videoId ? fetchGrokMediaPost(session, jar, input.videoId) : Promise.resolve(undefined)
|
|
176562
|
-
]);
|
|
176563
|
-
for (const candidate of candidates) {
|
|
176564
|
-
const videoUrl = extractGrokVideoUrl(candidate);
|
|
176565
|
-
if (videoUrl) {
|
|
176566
|
-
return videoUrl;
|
|
176567
|
-
}
|
|
176568
|
-
}
|
|
176569
|
-
await delay(GROK_VIDEO_POLL_INTERVAL_MS);
|
|
176570
|
-
}
|
|
176571
|
-
return;
|
|
176572
|
-
}
|
|
176573
176780
|
async function inspectGrokVideoJob(session, jar, input) {
|
|
176574
176781
|
const responseBodies = await Promise.all([
|
|
176575
176782
|
input.conversationId ? fetchGrokConversationResponses(session, jar, input.conversationId) : Promise.resolve(undefined),
|
|
@@ -176673,6 +176880,27 @@ async function downloadGrokAsset(session, jar, assetUrl, kind, input) {
|
|
|
176673
176880
|
await writeFile11(outputPath, decodeTlsBinaryBody(response.body));
|
|
176674
176881
|
return outputPath;
|
|
176675
176882
|
}
|
|
176883
|
+
async function downloadBrowserAccessibleAsset(client, assetUrl, kind, input) {
|
|
176884
|
+
const response = await client.requestWithResponse(assetUrl, {
|
|
176885
|
+
responseType: "arrayBuffer",
|
|
176886
|
+
expectedStatus: 200,
|
|
176887
|
+
headers: {
|
|
176888
|
+
accept: kind === "videos" ? "video/*,*/*;q=0.8" : "image/avif,image/webp,image/apng,image/*,*/*;q=0.8",
|
|
176889
|
+
referer: input.referer ?? GROK_IMAGINE_URL,
|
|
176890
|
+
"user-agent": GROK_USER_AGENT
|
|
176891
|
+
}
|
|
176892
|
+
});
|
|
176893
|
+
const outputPath = buildGrokAssetOutputPath(kind, input.prefix, assetUrl, input.outputDir);
|
|
176894
|
+
await ensureParentDirectory(outputPath);
|
|
176895
|
+
await writeFile11(outputPath, Buffer.from(response.data));
|
|
176896
|
+
return outputPath;
|
|
176897
|
+
}
|
|
176898
|
+
async function writeGrokBrowserAsset(source, kind, input) {
|
|
176899
|
+
const outputPath = buildGrokBrowserAssetOutputPath(kind, input.prefix, source, input.outputDir);
|
|
176900
|
+
await ensureParentDirectory(outputPath);
|
|
176901
|
+
await writeFile11(outputPath, decodeTlsBinaryBody(source));
|
|
176902
|
+
return outputPath;
|
|
176903
|
+
}
|
|
176676
176904
|
function buildGrokAssetOutputPath(kind, prefix, assetUrl, outputDir) {
|
|
176677
176905
|
const url2 = new URL(assetUrl);
|
|
176678
176906
|
const extension = extname10(url2.pathname) || (kind === "videos" ? ".mp4" : ".jpg");
|
|
@@ -176682,6 +176910,17 @@ function buildGrokAssetOutputPath(kind, prefix, assetUrl, outputDir) {
|
|
|
176682
176910
|
}
|
|
176683
176911
|
return getCachePath("grok", "generated", kind, fileName);
|
|
176684
176912
|
}
|
|
176913
|
+
function buildGrokBrowserAssetOutputPath(kind, prefix, source, outputDir) {
|
|
176914
|
+
if (!isDataUri(source)) {
|
|
176915
|
+
return buildGrokAssetOutputPath(kind, prefix, source, outputDir);
|
|
176916
|
+
}
|
|
176917
|
+
const extension = resolveDataUriExtension(source, kind);
|
|
176918
|
+
const fileName = `${sanitizeFileFragment(prefix)}-${randomUUID5()}${extension}`;
|
|
176919
|
+
if (outputDir) {
|
|
176920
|
+
return join7(outputDir, fileName);
|
|
176921
|
+
}
|
|
176922
|
+
return getCachePath("grok", "generated", kind, fileName);
|
|
176923
|
+
}
|
|
176685
176924
|
function sanitizeFileFragment(value) {
|
|
176686
176925
|
return value.replace(/[^a-z0-9._-]+/giu, "-").replace(/^-+|-+$/gu, "").slice(0, 80) || "grok";
|
|
176687
176926
|
}
|
|
@@ -176694,12 +176933,155 @@ function decodeTlsBinaryBody(body) {
|
|
|
176694
176933
|
}
|
|
176695
176934
|
return Buffer.from(body, "base64");
|
|
176696
176935
|
}
|
|
176936
|
+
function isDataUri(value) {
|
|
176937
|
+
return value.startsWith("data:");
|
|
176938
|
+
}
|
|
176939
|
+
function resolveDataUriExtension(source, kind) {
|
|
176940
|
+
const mimeMatch = source.match(/^data:([^;,]+)/u);
|
|
176941
|
+
const mime = mimeMatch?.[1]?.toLowerCase() ?? "";
|
|
176942
|
+
if (mime.endsWith("png")) {
|
|
176943
|
+
return ".png";
|
|
176944
|
+
}
|
|
176945
|
+
if (mime.endsWith("webp")) {
|
|
176946
|
+
return ".webp";
|
|
176947
|
+
}
|
|
176948
|
+
if (mime.endsWith("gif")) {
|
|
176949
|
+
return ".gif";
|
|
176950
|
+
}
|
|
176951
|
+
if (mime.endsWith("mp4")) {
|
|
176952
|
+
return ".mp4";
|
|
176953
|
+
}
|
|
176954
|
+
return kind === "videos" ? ".mp4" : ".jpg";
|
|
176955
|
+
}
|
|
176697
176956
|
function resolveGrokAssetUrl(assetPathOrUrl) {
|
|
176698
176957
|
if (/^https?:\/\//u.test(assetPathOrUrl)) {
|
|
176699
176958
|
return assetPathOrUrl;
|
|
176700
176959
|
}
|
|
176701
176960
|
return new URL(assetPathOrUrl.replace(/^\/+/u, ""), GROK_ASSET_BASE_URL).toString();
|
|
176702
176961
|
}
|
|
176962
|
+
function createGrokGeneratedAssetCollector(page, mode) {
|
|
176963
|
+
const assetUrls = new Set;
|
|
176964
|
+
let active = true;
|
|
176965
|
+
const onResponse = (response) => {
|
|
176966
|
+
if (!active || response.status() < 200 || response.status() >= 400) {
|
|
176967
|
+
return;
|
|
176968
|
+
}
|
|
176969
|
+
const url2 = response.url();
|
|
176970
|
+
if (!isBrowserGeneratedAssetUrl(url2, mode)) {
|
|
176971
|
+
return;
|
|
176972
|
+
}
|
|
176973
|
+
assetUrls.add(url2);
|
|
176974
|
+
};
|
|
176975
|
+
page.on("response", onResponse);
|
|
176976
|
+
return {
|
|
176977
|
+
stop: () => {
|
|
176978
|
+
if (!active) {
|
|
176979
|
+
return Array.from(assetUrls);
|
|
176980
|
+
}
|
|
176981
|
+
active = false;
|
|
176982
|
+
page.off("response", onResponse);
|
|
176983
|
+
return Array.from(assetUrls);
|
|
176984
|
+
}
|
|
176985
|
+
};
|
|
176986
|
+
}
|
|
176987
|
+
async function collectImagineAssetUrls(page, mode) {
|
|
176988
|
+
return page.evaluate((currentMode) => {
|
|
176989
|
+
const elements = Array.from(document.querySelectorAll(currentMode === "video" ? "video, source" : "img"));
|
|
176990
|
+
const urls = elements.map((node) => {
|
|
176991
|
+
if (!(node instanceof HTMLElement)) {
|
|
176992
|
+
return "";
|
|
176993
|
+
}
|
|
176994
|
+
const currentSrc = "currentSrc" in node ? String(node.currentSrc || "") : "";
|
|
176995
|
+
const src = currentSrc || node.getAttribute("src") || "";
|
|
176996
|
+
if (!src) {
|
|
176997
|
+
return "";
|
|
176998
|
+
}
|
|
176999
|
+
if (currentMode === "video") {
|
|
177000
|
+
return src.includes("/generated/") || src.includes(".mp4") ? src : "";
|
|
177001
|
+
}
|
|
177002
|
+
const alt = node.getAttribute("alt") || "";
|
|
177003
|
+
const naturalWidth = node instanceof HTMLImageElement ? node.naturalWidth || 0 : 0;
|
|
177004
|
+
const naturalHeight = node instanceof HTMLImageElement ? node.naturalHeight || 0 : 0;
|
|
177005
|
+
const isLargeInlineImage = src.startsWith("data:image/") && (naturalWidth >= 512 || naturalHeight >= 512);
|
|
177006
|
+
const isRemoteGeneratedImage = src.includes("/generated/") && !src.includes("preview_image");
|
|
177007
|
+
const isGeneratedImage = isLargeInlineImage || isRemoteGeneratedImage || alt === "Generated image" && (isLargeInlineImage || isRemoteGeneratedImage);
|
|
177008
|
+
if (!isGeneratedImage || alt === "pfp" || alt === "Most recent favorite") {
|
|
177009
|
+
return "";
|
|
177010
|
+
}
|
|
177011
|
+
return src;
|
|
177012
|
+
}).filter((value) => Boolean(value));
|
|
177013
|
+
return Array.from(new Set(urls));
|
|
177014
|
+
}, mode);
|
|
177015
|
+
}
|
|
177016
|
+
function selectRecentImagineAssetUrls(assetUrls, mode) {
|
|
177017
|
+
const unique = dedupeValues(assetUrls);
|
|
177018
|
+
if (mode === "video") {
|
|
177019
|
+
return unique.slice(-1);
|
|
177020
|
+
}
|
|
177021
|
+
const remoteFinal = unique.filter((url2) => !isDataUri(url2) && !isPreviewImagineAssetUrl(url2));
|
|
177022
|
+
const inline = unique.filter((url2) => isDataUri(url2));
|
|
177023
|
+
const remotePreview = unique.filter((url2) => !isDataUri(url2) && isPreviewImagineAssetUrl(url2));
|
|
177024
|
+
if (inline.length > 0) {
|
|
177025
|
+
const bestInline = [...inline].sort((left, right) => left.length - right.length).at(-1);
|
|
177026
|
+
return bestInline ? [bestInline] : [];
|
|
177027
|
+
}
|
|
177028
|
+
if (remoteFinal.length > 0) {
|
|
177029
|
+
return remoteFinal.slice(-1);
|
|
177030
|
+
}
|
|
177031
|
+
return remotePreview.slice(-1);
|
|
177032
|
+
}
|
|
177033
|
+
function isBrowserGeneratedAssetUrl(url2, mode) {
|
|
177034
|
+
try {
|
|
177035
|
+
const parsed = new URL(url2);
|
|
177036
|
+
if (parsed.hostname !== "assets.grok.com" || !parsed.pathname.includes("/generated/")) {
|
|
177037
|
+
return false;
|
|
177038
|
+
}
|
|
177039
|
+
const path2 = parsed.pathname.toLowerCase();
|
|
177040
|
+
if (mode === "video") {
|
|
177041
|
+
return path2.endsWith(".mp4") || path2.endsWith(".mov") || path2.endsWith(".webm") || path2.includes("generated_video");
|
|
177042
|
+
}
|
|
177043
|
+
if (path2.includes("preview_image")) {
|
|
177044
|
+
return false;
|
|
177045
|
+
}
|
|
177046
|
+
return path2.endsWith(".jpg") || path2.endsWith(".jpeg") || path2.endsWith(".png") || path2.endsWith(".webp") || path2.includes("generated_image");
|
|
177047
|
+
} catch {
|
|
177048
|
+
return false;
|
|
177049
|
+
}
|
|
177050
|
+
}
|
|
177051
|
+
function isPreviewImagineAssetUrl(url2) {
|
|
177052
|
+
try {
|
|
177053
|
+
const parsed = new URL(url2);
|
|
177054
|
+
return parsed.pathname.toLowerCase().includes("preview_image");
|
|
177055
|
+
} catch {
|
|
177056
|
+
return false;
|
|
177057
|
+
}
|
|
177058
|
+
}
|
|
177059
|
+
function resolveBrowserImagineImageUrls(input) {
|
|
177060
|
+
const browserOutputUrls = selectRecentImagineAssetUrls(input.assetUrls, "image");
|
|
177061
|
+
if (browserOutputUrls.length > 0) {
|
|
177062
|
+
return browserOutputUrls;
|
|
177063
|
+
}
|
|
177064
|
+
const parsedOutputUrls = (input.parsed?.imageAssets ?? []).map((asset) => resolveGrokAssetUrl(asset.assetPath));
|
|
177065
|
+
if (parsedOutputUrls.length > 0) {
|
|
177066
|
+
return dedupeValues(parsedOutputUrls);
|
|
177067
|
+
}
|
|
177068
|
+
return [];
|
|
177069
|
+
}
|
|
177070
|
+
function resolveBrowserImagineVideoUrl(input, latestVideoUpdate) {
|
|
177071
|
+
if (latestVideoUpdate?.videoUrl) {
|
|
177072
|
+
return resolveGrokAssetUrl(latestVideoUpdate.videoUrl);
|
|
177073
|
+
}
|
|
177074
|
+
return selectRecentImagineAssetUrls(input.assetUrls, "video")[0];
|
|
177075
|
+
}
|
|
177076
|
+
function extractGrokImaginePostId(url2) {
|
|
177077
|
+
try {
|
|
177078
|
+
const parsed = new URL(url2);
|
|
177079
|
+
const match = parsed.pathname.match(/\/imagine\/post\/([^/]+)$/u);
|
|
177080
|
+
return match?.[1];
|
|
177081
|
+
} catch {
|
|
177082
|
+
return;
|
|
177083
|
+
}
|
|
177084
|
+
}
|
|
176703
177085
|
function parseGrokGeneratedImageAsset(jsonData) {
|
|
176704
177086
|
if (!jsonData) {
|
|
176705
177087
|
return;
|
|
@@ -176761,9 +177143,6 @@ function shouldReplaceGrokImageAsset(current, next) {
|
|
|
176761
177143
|
}
|
|
176762
177144
|
return next.assetPath.length >= current.assetPath.length;
|
|
176763
177145
|
}
|
|
176764
|
-
function selectPrimaryGrokImageAsset(assets) {
|
|
176765
|
-
return selectFinalGrokImageAssets(assets)[0];
|
|
176766
|
-
}
|
|
176767
177146
|
function selectLatestGrokVideoUpdate(updates) {
|
|
176768
177147
|
let selected;
|
|
176769
177148
|
for (const update of updates) {
|
|
@@ -177165,7 +177544,9 @@ class GrokAdapter extends CookieLlmAdapter {
|
|
|
177165
177544
|
try {
|
|
177166
177545
|
const result = await this.service.executeImage(client, {
|
|
177167
177546
|
prompt,
|
|
177168
|
-
model: input.model?.trim() || "grok-3"
|
|
177547
|
+
model: input.model?.trim() || "grok-3",
|
|
177548
|
+
browser: Boolean(input.browser),
|
|
177549
|
+
browserTimeoutSeconds: input.browserTimeoutSeconds
|
|
177169
177550
|
});
|
|
177170
177551
|
await this.persistActiveSession(session, client.jar, result.model);
|
|
177171
177552
|
const { job, path: jobPath } = await this.upsertImageJob({
|
|
@@ -177214,7 +177595,9 @@ class GrokAdapter extends CookieLlmAdapter {
|
|
|
177214
177595
|
try {
|
|
177215
177596
|
const result = await this.service.executeVideo(client, {
|
|
177216
177597
|
prompt,
|
|
177217
|
-
model: input.model?.trim() || "grok-3"
|
|
177598
|
+
model: input.model?.trim() || "grok-3",
|
|
177599
|
+
browser: Boolean(input.browser),
|
|
177600
|
+
browserTimeoutSeconds: input.browserTimeoutSeconds
|
|
177218
177601
|
});
|
|
177219
177602
|
await this.persistActiveSession(session, client.jar, result.model);
|
|
177220
177603
|
const actionMessage = result.status === "completed" ? `Grok generated a video using ${result.model}.` : `Grok accepted the video generation job using ${result.model}, but the final asset URL is still pending.`;
|
|
@@ -177443,7 +177826,9 @@ class GrokAdapter extends CookieLlmAdapter {
|
|
|
177443
177826
|
try {
|
|
177444
177827
|
const result = await this.service.executeText(client, {
|
|
177445
177828
|
prompt: input.prompt,
|
|
177446
|
-
model: input.model
|
|
177829
|
+
model: input.model,
|
|
177830
|
+
browser: Boolean(input.browser),
|
|
177831
|
+
browserTimeoutSeconds: input.browserTimeoutSeconds
|
|
177447
177832
|
});
|
|
177448
177833
|
await this.persistExistingSession(session, {
|
|
177449
177834
|
jar: client.jar,
|
|
@@ -177471,7 +177856,8 @@ class GrokAdapter extends CookieLlmAdapter {
|
|
|
177471
177856
|
conversationId: result.conversationId,
|
|
177472
177857
|
responseId: result.responseId,
|
|
177473
177858
|
outputText: result.outputText,
|
|
177474
|
-
followUpSuggestions: result.followUpSuggestions
|
|
177859
|
+
followUpSuggestions: result.followUpSuggestions,
|
|
177860
|
+
source: input.browser ? "browser" : undefined
|
|
177475
177861
|
}
|
|
177476
177862
|
};
|
|
177477
177863
|
} catch (error49) {
|
|
@@ -177748,12 +178134,16 @@ function createGrokCapabilities(adapter) {
|
|
|
177748
178134
|
successMessage: "Grok text prompt completed.",
|
|
177749
178135
|
options: [
|
|
177750
178136
|
{ flags: "--account <name>", description: "Optional saved session name to use" },
|
|
177751
|
-
{ flags: "--model <name>", description: "Optional provider model or mode hint" }
|
|
178137
|
+
{ flags: "--model <name>", description: "Optional provider model or mode hint" },
|
|
178138
|
+
{ flags: "--browser", description: "Force Grok to run the prompt through the real web app in a browser context" },
|
|
178139
|
+
{ flags: "--browser-timeout <seconds>", description: "Maximum seconds to allow the browser-backed Grok flow to complete", parser: parsePositiveSeconds }
|
|
177752
178140
|
],
|
|
177753
178141
|
action: ({ args, options }) => adapter.text({
|
|
177754
178142
|
account: options.account,
|
|
177755
178143
|
model: options.model,
|
|
177756
|
-
prompt: args.map(String).join(" ").trim()
|
|
178144
|
+
prompt: args.map(String).join(" ").trim(),
|
|
178145
|
+
browser: Boolean(options.browser),
|
|
178146
|
+
browserTimeoutSeconds: options.browserTimeout
|
|
177757
178147
|
}),
|
|
177758
178148
|
onSuccess: printCookieLlmTextResult
|
|
177759
178149
|
});
|
|
@@ -177765,12 +178155,16 @@ function createGrokCapabilities(adapter) {
|
|
|
177765
178155
|
successMessage: "Grok image generation completed.",
|
|
177766
178156
|
options: [
|
|
177767
178157
|
{ flags: "--account <name>", description: "Optional saved session name to use" },
|
|
177768
|
-
{ flags: "--model <name>", description: "Optional provider model or mode hint" }
|
|
178158
|
+
{ flags: "--model <name>", description: "Optional provider model or mode hint" },
|
|
178159
|
+
{ flags: "--browser", description: "Force Grok to run image generation through the real web app in a browser context" },
|
|
178160
|
+
{ flags: "--browser-timeout <seconds>", description: "Maximum seconds to allow the browser-backed Grok flow to complete", parser: parsePositiveSeconds }
|
|
177769
178161
|
],
|
|
177770
178162
|
action: ({ args, options }) => adapter.generateImage({
|
|
177771
178163
|
account: options.account,
|
|
177772
178164
|
model: options.model,
|
|
177773
|
-
prompt: args.map(String).join(" ").trim()
|
|
178165
|
+
prompt: args.map(String).join(" ").trim(),
|
|
178166
|
+
browser: Boolean(options.browser),
|
|
178167
|
+
browserTimeoutSeconds: options.browserTimeout
|
|
177774
178168
|
}),
|
|
177775
178169
|
onSuccess: printCookieLlmMediaResult
|
|
177776
178170
|
});
|
|
@@ -177799,12 +178193,16 @@ function createGrokCapabilities(adapter) {
|
|
|
177799
178193
|
successMessage: "Grok video generation completed.",
|
|
177800
178194
|
options: [
|
|
177801
178195
|
{ flags: "--account <name>", description: "Optional saved session name to use" },
|
|
177802
|
-
{ flags: "--model <name>", description: "Optional provider model or mode hint" }
|
|
178196
|
+
{ flags: "--model <name>", description: "Optional provider model or mode hint" },
|
|
178197
|
+
{ flags: "--browser", description: "Force Grok to run video generation through the real web app in a browser context" },
|
|
178198
|
+
{ flags: "--browser-timeout <seconds>", description: "Maximum seconds to allow the browser-backed Grok flow to complete", parser: parsePositiveSeconds }
|
|
177803
178199
|
],
|
|
177804
178200
|
action: ({ args, options }) => adapter.generateVideo({
|
|
177805
178201
|
account: options.account,
|
|
177806
178202
|
model: options.model,
|
|
177807
|
-
prompt: args.map(String).join(" ").trim()
|
|
178203
|
+
prompt: args.map(String).join(" ").trim(),
|
|
178204
|
+
browser: Boolean(options.browser),
|
|
178205
|
+
browserTimeoutSeconds: options.browserTimeout
|
|
177808
178206
|
}),
|
|
177809
178207
|
onSuccess: printCookieLlmMediaResult
|
|
177810
178208
|
});
|
|
@@ -177901,11 +178299,12 @@ var grokPlatformDefinition = {
|
|
|
177901
178299
|
adapter: grokAdapter,
|
|
177902
178300
|
capabilities: createGrokCapabilities(grokAdapter),
|
|
177903
178301
|
examples: [
|
|
177904
|
-
"autocli grok login --cookies ./grok.cookies.json",
|
|
177905
|
-
'autocli grok text "Summarize this sprint"',
|
|
177906
|
-
'autocli grok
|
|
177907
|
-
|
|
177908
|
-
|
|
178302
|
+
"autocli llm grok login --cookies ./grok.cookies.json",
|
|
178303
|
+
'autocli llm grok text "Summarize this sprint"',
|
|
178304
|
+
'autocli llm grok text "Summarize this sprint" --browser',
|
|
178305
|
+
'autocli llm grok image "Minimal orange fox logo on white background" --browser',
|
|
178306
|
+
"autocli llm grok image-download <job-id>",
|
|
178307
|
+
'autocli llm grok video "Cyberpunk city flythrough" --browser'
|
|
177909
178308
|
]
|
|
177910
178309
|
};
|
|
177911
178310
|
|