w-dispatch-ai 1.0.1 → 1.0.2

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/docs/global.html CHANGED
@@ -29,7 +29,7 @@
29
29
  <nav >
30
30
 
31
31
 
32
- <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#WDispatchAi">WDispatchAi</a></li><li><a href="global.html#adapters">adapters</a></li><li><a href="global.html#dispatchAi">dispatchAi</a></li><li><a href="global.html#dispatchAiFallback">dispatchAiFallback</a></li><li><a href="global.html#dispatchClaude">dispatchClaude</a></li><li><a href="global.html#dispatchCodex">dispatchCodex</a></li><li><a href="global.html#dispatchOpencode">dispatchOpencode</a></li><li><a href="global.html#getCliArgs">getCliArgs</a></li><li><a href="global.html#getErrorResult">getErrorResult</a></li><li><a href="global.html#isKeyIndependentFail">isKeyIndependentFail</a></li></ul>
32
+ <h2><a href="index.html">Home</a></h2><h3>Global</h3><ul><li><a href="global.html#WDispatchAi">WDispatchAi</a></li><li><a href="global.html#adapters">adapters</a></li><li><a href="global.html#dispatchAi">dispatchAi</a></li><li><a href="global.html#dispatchAiFallback">dispatchAiFallback</a></li><li><a href="global.html#dispatchAntigravity">dispatchAntigravity</a></li><li><a href="global.html#dispatchClaude">dispatchClaude</a></li><li><a href="global.html#dispatchCodex">dispatchCodex</a></li><li><a href="global.html#dispatchOpencode">dispatchOpencode</a></li><li><a href="global.html#getCliArgs">getCliArgs</a></li><li><a href="global.html#getErrorResult">getErrorResult</a></li><li><a href="global.html#isKeyIndependentFail">isKeyIndependentFail</a></li></ul>
33
33
 
34
34
  </nav>
35
35
 
@@ -140,7 +140,7 @@
140
140
 
141
141
  <dt class="tag-source">Source:</dt>
142
142
  <dd class="tag-source"><ul class="dummy"><li>
143
- <a href="WDispatchAi.mjs.html">WDispatchAi.mjs</a>, <a href="WDispatchAi.mjs.html#line30">line 30</a>
143
+ <a href="WDispatchAi.mjs.html">WDispatchAi.mjs</a>, <a href="WDispatchAi.mjs.html#line31">line 31</a>
144
144
  </li></ul></dd>
145
145
 
146
146
 
@@ -191,7 +191,7 @@
191
191
 
192
192
  <h5 class="h5-examples">Example</h5>
193
193
 
194
- <pre class="prettyprint"><code>詳見dispatchAi、dispatchAiFallback、dispatchOpencode、dispatchClaude、dispatchCodex範例</code></pre>
194
+ <pre class="prettyprint"><code>詳見dispatchAi、dispatchAiFallback、dispatchOpencode、dispatchClaude、dispatchCodex、dispatchAntigravity範例</code></pre>
195
195
 
196
196
 
197
197
 
@@ -214,7 +214,7 @@
214
214
 
215
215
  <dt class="tag-source">Source:</dt>
216
216
  <dd class="tag-source"><ul class="dummy"><li>
217
- <a href="adapters.mjs.html">adapters.mjs</a>, <a href="adapters.mjs.html#line21">line 21</a>
217
+ <a href="adapters.mjs.html">adapters.mjs</a>, <a href="adapters.mjs.html#line22">line 22</a>
218
218
  </li></ul></dd>
219
219
 
220
220
 
@@ -270,7 +270,7 @@
270
270
  <pre class="prettyprint"><code>import adapters from './src/adapters.mjs'
271
271
 
272
272
  console.log(Object.keys(adapters))
273
- // => ['opencode', 'claude', 'codex']</code></pre>
273
+ // => ['opencode', 'claude', 'codex', 'antigravity']</code></pre>
274
274
 
275
275
 
276
276
 
@@ -1276,6 +1276,729 @@ await test()
1276
1276
 
1277
1277
 
1278
1278
 
1279
+ <h4 class="name" id="dispatchAntigravity"><span class="type-signature type-signature-async">(async) </span>dispatchAntigravity<span class="signature">(prompt, opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
1280
+
1281
+
1282
+
1283
+
1284
+
1285
+
1286
+ <dl class="details">
1287
+
1288
+ <dt class="tag-description">Description:</dt>
1289
+ <dd class="tag-description"><ul class="dummy"><li><p>以Google Antigravity CLI(agy)呼叫AI模型</p>
1290
+ <p>特點:
1291
+ prompt作為<code>--print</code>旗標之值傳遞而非stdin(agy介面如此,塞stdin會進互動模式卡住),
1292
+ 故prompt受命令列長度上限約束,超過30000字元回傳錯誤結果物件;
1293
+ model須為<code>agy models</code>第一欄之slug(如gemini-3.6-flash-low),注意agy錯誤訊息列出的是顯示名稱而非slug;
1294
+ 帶檔位之slug(-high/-medium/-low結尾)與effort同時給定且檔位不一致時agy回conflicts錯誤(一致則放行),
1295
+ effort需agy&gt;=1.1.11,建議搭配不帶檔位之基礎slug(如gemini-3.1-pro)使用;
1296
+ 預設帶<code>--dangerously-skip-permissions</code>令非互動print模式不卡權限確認,可給予skipPermissions為false保留權限閘門;
1297
+ agy自身之--print-timeout未給時由timeoutMs推導並預留30秒緩衝,令CLI先於外層逾時;
1298
+ 沿用agy既有OAuth登入狀態(首次須於桌面互動模式完成登入);
1299
+ 本函數不會reject,一律以結果物件之ok與error欄位回報成敗</p></li></ul></dd>
1300
+
1301
+
1302
+
1303
+ <dt class="tag-source">Source:</dt>
1304
+ <dd class="tag-source"><ul class="dummy"><li>
1305
+ <a href="dispatchAntigravity.mjs.html">dispatchAntigravity.mjs</a>, <a href="dispatchAntigravity.mjs.html#line105">line 105</a>
1306
+ </li></ul></dd>
1307
+
1308
+
1309
+
1310
+
1311
+
1312
+
1313
+
1314
+
1315
+
1316
+
1317
+
1318
+
1319
+
1320
+
1321
+
1322
+
1323
+
1324
+
1325
+
1326
+
1327
+
1328
+
1329
+
1330
+
1331
+
1332
+
1333
+
1334
+
1335
+
1336
+
1337
+
1338
+ </dl>
1339
+
1340
+
1341
+
1342
+
1343
+
1344
+
1345
+
1346
+
1347
+
1348
+
1349
+
1350
+ <h5 class="h5-examples">Example</h5>
1351
+
1352
+ <pre class="prettyprint"><code>//need agy cli in system PATH, and OAuth login completed
1353
+
1354
+ import dispatchAntigravity from './src/dispatchAntigravity.mjs'
1355
+
1356
+ let test = async () => {
1357
+
1358
+ let r = await dispatchAntigravity('請只回覆兩個字:完成', { model: 'gemini-3.6-flash-low' })
1359
+ console.log(r.ok, r.stdout.trim())
1360
+ // => true 完成
1361
+
1362
+ //基礎slug搭配effort(不可用帶檔位之slug併用effort)
1363
+ let r2 = await dispatchAntigravity('請只回覆兩個字:完成', { model: 'gemini-3.1-pro', effort: 'low' })
1364
+ console.log(r2.ok)
1365
+ // => true
1366
+
1367
+ let re = await dispatchAntigravity('')
1368
+ console.log(re.ok, re.error)
1369
+ // => false 'prompt must be a non-empty string'
1370
+
1371
+ }
1372
+ await test()
1373
+ .catch((err) => {
1374
+ console.log(err)
1375
+ })</code></pre>
1376
+
1377
+
1378
+
1379
+
1380
+ <h5 class="h5-parameters">Parameters:</h5>
1381
+
1382
+
1383
+ <table class="params">
1384
+ <thead>
1385
+ <tr>
1386
+
1387
+ <th>Name</th>
1388
+
1389
+
1390
+ <th>Type</th>
1391
+
1392
+
1393
+ <th>Attributes</th>
1394
+
1395
+
1396
+
1397
+ <th>Default</th>
1398
+
1399
+
1400
+ <th class="last">Description</th>
1401
+ </tr>
1402
+ </thead>
1403
+
1404
+ <tbody>
1405
+
1406
+
1407
+ <tr>
1408
+
1409
+ <td class="name"><code>prompt</code></td>
1410
+
1411
+
1412
+ <td class="type">
1413
+
1414
+
1415
+ <span class="param-type">String</span>
1416
+
1417
+
1418
+
1419
+
1420
+ </td>
1421
+
1422
+
1423
+ <td class="attributes">
1424
+
1425
+
1426
+
1427
+
1428
+
1429
+ </td>
1430
+
1431
+
1432
+
1433
+ <td class="default">
1434
+
1435
+ </td>
1436
+
1437
+
1438
+ <td class="description last"><p>輸入提示詞字串,作為<code>--print</code>旗標之值傳遞,長度上限30000字元</p></td>
1439
+ </tr>
1440
+
1441
+
1442
+
1443
+ <tr>
1444
+
1445
+ <td class="name"><code>opt</code></td>
1446
+
1447
+
1448
+ <td class="type">
1449
+
1450
+
1451
+ <span class="param-type">Object</span>
1452
+
1453
+
1454
+
1455
+
1456
+ </td>
1457
+
1458
+
1459
+ <td class="attributes">
1460
+
1461
+ &lt;optional><br>
1462
+
1463
+
1464
+
1465
+
1466
+
1467
+ </td>
1468
+
1469
+
1470
+
1471
+ <td class="default">
1472
+
1473
+ <code>{}</code>
1474
+
1475
+ </td>
1476
+
1477
+
1478
+ <td class="description last"><p>輸入設定物件,預設{}</p>
1479
+ <h6>Properties</h6>
1480
+
1481
+
1482
+ <table class="params">
1483
+ <thead>
1484
+ <tr>
1485
+
1486
+ <th>Name</th>
1487
+
1488
+
1489
+ <th>Type</th>
1490
+
1491
+
1492
+ <th>Attributes</th>
1493
+
1494
+
1495
+
1496
+ <th>Default</th>
1497
+
1498
+
1499
+ <th class="last">Description</th>
1500
+ </tr>
1501
+ </thead>
1502
+
1503
+ <tbody>
1504
+
1505
+
1506
+ <tr>
1507
+
1508
+ <td class="name"><code>exe</code></td>
1509
+
1510
+
1511
+ <td class="type">
1512
+
1513
+
1514
+ <span class="param-type">String</span>
1515
+
1516
+
1517
+
1518
+
1519
+ </td>
1520
+
1521
+
1522
+ <td class="attributes">
1523
+
1524
+ &lt;optional><br>
1525
+
1526
+
1527
+
1528
+
1529
+
1530
+ </td>
1531
+
1532
+
1533
+
1534
+ <td class="default">
1535
+
1536
+ <code>'agy'</code>
1537
+
1538
+ </td>
1539
+
1540
+
1541
+ <td class="description last"><p>輸入agy執行檔名稱或絕對路徑字串,命令名為agy非antigravity,給予名稱時由execCli自系統PATH解析,預設'agy'</p></td>
1542
+ </tr>
1543
+
1544
+
1545
+
1546
+ <tr>
1547
+
1548
+ <td class="name"><code>model</code></td>
1549
+
1550
+
1551
+ <td class="type">
1552
+
1553
+
1554
+ <span class="param-type">String</span>
1555
+
1556
+
1557
+
1558
+
1559
+ </td>
1560
+
1561
+
1562
+ <td class="attributes">
1563
+
1564
+ &lt;optional><br>
1565
+
1566
+
1567
+
1568
+
1569
+
1570
+ </td>
1571
+
1572
+
1573
+
1574
+ <td class="default">
1575
+
1576
+ <code>''</code>
1577
+
1578
+ </td>
1579
+
1580
+
1581
+ <td class="description last"><p>輸入模型slug字串,須為<code>agy models</code>第一欄之slug,例如'gemini-3.6-flash-low'、'gemini-3.1-pro-high',預設''代表不帶<code>--model</code>旗標由agy自行決定</p></td>
1582
+ </tr>
1583
+
1584
+
1585
+
1586
+ <tr>
1587
+
1588
+ <td class="name"><code>effort</code></td>
1589
+
1590
+
1591
+ <td class="type">
1592
+
1593
+
1594
+ <span class="param-type">String</span>
1595
+
1596
+
1597
+
1598
+
1599
+ </td>
1600
+
1601
+
1602
+ <td class="attributes">
1603
+
1604
+ &lt;optional><br>
1605
+
1606
+
1607
+
1608
+
1609
+
1610
+ </td>
1611
+
1612
+
1613
+
1614
+ <td class="default">
1615
+
1616
+ <code>''</code>
1617
+
1618
+ </td>
1619
+
1620
+
1621
+ <td class="description last"><p>輸入推理深度字串,可選'low'、'medium'、'high',需agy&gt;=1.1.11,建議搭配不帶檔位之基礎slug;與帶檔位slug併用且檔位不一致時agy回conflicts錯誤,預設''代表不帶</p></td>
1622
+ </tr>
1623
+
1624
+
1625
+
1626
+ <tr>
1627
+
1628
+ <td class="name"><code>skipPermissions</code></td>
1629
+
1630
+
1631
+ <td class="type">
1632
+
1633
+
1634
+ <span class="param-type">Boolean</span>
1635
+
1636
+
1637
+
1638
+
1639
+ </td>
1640
+
1641
+
1642
+ <td class="attributes">
1643
+
1644
+ &lt;optional><br>
1645
+
1646
+
1647
+
1648
+
1649
+
1650
+ </td>
1651
+
1652
+
1653
+
1654
+ <td class="default">
1655
+
1656
+ <code>true</code>
1657
+
1658
+ </td>
1659
+
1660
+
1661
+ <td class="description last"><p>輸入是否帶<code>--dangerously-skip-permissions</code>旗標布林值,false代表保留CLI權限閘門,預設true</p></td>
1662
+ </tr>
1663
+
1664
+
1665
+
1666
+ <tr>
1667
+
1668
+ <td class="name"><code>printTimeout</code></td>
1669
+
1670
+
1671
+ <td class="type">
1672
+
1673
+
1674
+ <span class="param-type">String</span>
1675
+
1676
+
1677
+
1678
+
1679
+ </td>
1680
+
1681
+
1682
+ <td class="attributes">
1683
+
1684
+ &lt;optional><br>
1685
+
1686
+
1687
+
1688
+
1689
+
1690
+ </td>
1691
+
1692
+
1693
+
1694
+ <td class="default">
1695
+
1696
+ <code>''</code>
1697
+
1698
+ </td>
1699
+
1700
+
1701
+ <td class="description last"><p>輸入agy自身等待上限字串(如'10m'、'570s'),預設''代表由timeoutMs推導(扣30秒緩衝,下限30秒)</p></td>
1702
+ </tr>
1703
+
1704
+
1705
+
1706
+ <tr>
1707
+
1708
+ <td class="name"><code>addDirs</code></td>
1709
+
1710
+
1711
+ <td class="type">
1712
+
1713
+
1714
+ <span class="param-type">Array</span>
1715
+
1716
+
1717
+
1718
+
1719
+ </td>
1720
+
1721
+
1722
+ <td class="attributes">
1723
+
1724
+ &lt;optional><br>
1725
+
1726
+
1727
+
1728
+
1729
+
1730
+ </td>
1731
+
1732
+
1733
+
1734
+ <td class="default">
1735
+
1736
+ <code>[]</code>
1737
+
1738
+ </td>
1739
+
1740
+
1741
+ <td class="description last"><p>輸入加入workspace之目錄字串陣列,逐項展開為<code>--add-dir</code>,預設[]</p></td>
1742
+ </tr>
1743
+
1744
+
1745
+
1746
+ <tr>
1747
+
1748
+ <td class="name"><code>extraArgs</code></td>
1749
+
1750
+
1751
+ <td class="type">
1752
+
1753
+
1754
+ <span class="param-type">Array</span>
1755
+
1756
+
1757
+
1758
+
1759
+ </td>
1760
+
1761
+
1762
+ <td class="attributes">
1763
+
1764
+ &lt;optional><br>
1765
+
1766
+
1767
+
1768
+
1769
+
1770
+ </td>
1771
+
1772
+
1773
+
1774
+ <td class="default">
1775
+
1776
+ <code>[]</code>
1777
+
1778
+ </td>
1779
+
1780
+
1781
+ <td class="description last"><p>輸入額外命令列旗標字串陣列(如--output-format、--json-schema、--mode),將接於固定旗標之後、<code>--print</code>之前,預設[]</p></td>
1782
+ </tr>
1783
+
1784
+
1785
+
1786
+ <tr>
1787
+
1788
+ <td class="name"><code>timeoutMs</code></td>
1789
+
1790
+
1791
+ <td class="type">
1792
+
1793
+
1794
+ <span class="param-type">Number</span>
1795
+
1796
+
1797
+
1798
+
1799
+ </td>
1800
+
1801
+
1802
+ <td class="attributes">
1803
+
1804
+ &lt;optional><br>
1805
+
1806
+
1807
+
1808
+
1809
+
1810
+ </td>
1811
+
1812
+
1813
+
1814
+ <td class="default">
1815
+
1816
+ <code>300000</code>
1817
+
1818
+ </td>
1819
+
1820
+
1821
+ <td class="description last"><p>輸入逾時毫秒正整數,逾時將強制關閉子進程及其子孫程序,agy為agent型CLI故預設較長之300000,預設300000</p></td>
1822
+ </tr>
1823
+
1824
+
1825
+
1826
+ <tr>
1827
+
1828
+ <td class="name"><code>cwd</code></td>
1829
+
1830
+
1831
+ <td class="type">
1832
+
1833
+
1834
+ <span class="param-type">String</span>
1835
+
1836
+
1837
+
1838
+
1839
+ </td>
1840
+
1841
+
1842
+ <td class="attributes">
1843
+
1844
+ &lt;optional><br>
1845
+
1846
+
1847
+
1848
+
1849
+
1850
+ </td>
1851
+
1852
+
1853
+
1854
+ <td class="default">
1855
+
1856
+ <code>process.cwd()</code>
1857
+
1858
+ </td>
1859
+
1860
+
1861
+ <td class="description last"><p>輸入子進程工作目錄字串,預設process.cwd()</p></td>
1862
+ </tr>
1863
+
1864
+
1865
+
1866
+ <tr>
1867
+
1868
+ <td class="name"><code>validate</code></td>
1869
+
1870
+
1871
+ <td class="type">
1872
+
1873
+
1874
+ <span class="param-type">String</span>
1875
+ |
1876
+
1877
+ <span class="param-type">function</span>
1878
+
1879
+
1880
+
1881
+
1882
+ </td>
1883
+
1884
+
1885
+ <td class="attributes">
1886
+
1887
+ &lt;optional><br>
1888
+
1889
+
1890
+
1891
+
1892
+
1893
+ </td>
1894
+
1895
+
1896
+
1897
+ <td class="default">
1898
+
1899
+ </td>
1900
+
1901
+
1902
+ <td class="description last"><p>輸入stdout驗證規則字串或自訂驗證函數,規則字串支援'nonempty'、'json'、'min:100',多規則可用逗號串接,預設undefined代表不驗證</p></td>
1903
+ </tr>
1904
+
1905
+
1906
+
1907
+ <tr>
1908
+
1909
+ <td class="name"><code>maxRetries</code></td>
1910
+
1911
+
1912
+ <td class="type">
1913
+
1914
+
1915
+ <span class="param-type">Number</span>
1916
+
1917
+
1918
+
1919
+
1920
+ </td>
1921
+
1922
+
1923
+ <td class="attributes">
1924
+
1925
+ &lt;optional><br>
1926
+
1927
+
1928
+
1929
+
1930
+
1931
+ </td>
1932
+
1933
+
1934
+
1935
+ <td class="default">
1936
+
1937
+ <code>0</code>
1938
+
1939
+ </td>
1940
+
1941
+
1942
+ <td class="description last"><p>輸入失敗後最大重試次數非負整數,預設0</p></td>
1943
+ </tr>
1944
+
1945
+
1946
+ </tbody>
1947
+ </table>
1948
+
1949
+ </td>
1950
+ </tr>
1951
+
1952
+
1953
+ </tbody>
1954
+ </table>
1955
+
1956
+
1957
+
1958
+
1959
+
1960
+
1961
+
1962
+
1963
+
1964
+
1965
+
1966
+
1967
+
1968
+
1969
+
1970
+
1971
+ <h5 class="h5-returns">Returns:</h5>
1972
+
1973
+
1974
+ <div class="param-desc">
1975
+ <p>回傳Promise,resolve回傳結果物件,內含ok(是否成功布林值)、stdout(標準輸出字串)、stderr(標準錯誤字串)、code(離開碼)、error(錯誤訊息字串,成功時為空字串)、durationMs(耗時毫秒)、attempts(實際嘗試次數),本函數不會reject</p>
1976
+ </div>
1977
+
1978
+
1979
+
1980
+ <dl class="param-type">
1981
+ <dt>
1982
+ Type
1983
+ </dt>
1984
+ <dd>
1985
+
1986
+ <span class="param-type">Promise</span>
1987
+
1988
+
1989
+
1990
+ </dd>
1991
+ </dl>
1992
+
1993
+
1994
+
1995
+
1996
+
1997
+
1998
+
1999
+
2000
+
2001
+
1279
2002
  <h4 class="name" id="dispatchClaude"><span class="type-signature type-signature-async">(async) </span>dispatchClaude<span class="signature">(prompt, opt<span class="signature-attributes">opt</span>)</span><span class="type-signature"> &rarr; {Promise}</span></h4>
1280
2003
 
1281
2004
 
@@ -3782,7 +4505,7 @@ console.log(getErrorResult(null).error)
3782
4505
  <br class="clear">
3783
4506
 
3784
4507
  <footer>
3785
- Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Sun Aug 09 2026 23:14:54 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
4508
+ Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 4.0.5</a> on Mon Aug 10 2026 09:36:49 GMT+0800 (台北標準時間) using the <a href="https://github.com/clenemt/docdash">docdash</a> theme.
3786
4509
  </footer>
3787
4510
 
3788
4511
  <script>prettyPrint();</script>