@integrity-labs/agt-cli 0.27.150-test.15 → 0.27.151

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.
@@ -1786,8 +1786,133 @@ addFormats(ajv);
1786
1786
  var compiledMetaSchema = ajv.compile(context_meta_schema_default);
1787
1787
 
1788
1788
  // ../../packages/core/dist/integrations/augmented-live/codec.js
1789
+ var CODEC_VERSION = 1;
1790
+ var DEFAULT_KEYFRAME_INTERVAL = 10;
1791
+ var DEFAULT_KEYFRAME_INTERVAL_MS = 5e3;
1789
1792
  var DEFAULT_CHUNK_BUDGET_BYTES = 180 * 1024;
1790
1793
  var textEncoder = new TextEncoder();
1794
+ function byteLength(value) {
1795
+ return textEncoder.encode(value).length;
1796
+ }
1797
+ function frameByteLength(frame) {
1798
+ return byteLength(JSON.stringify(frame));
1799
+ }
1800
+ function diffStrings(base, next) {
1801
+ const baseLen = base.length;
1802
+ const nextLen = next.length;
1803
+ let prefix = 0;
1804
+ const maxPrefix = Math.min(baseLen, nextLen);
1805
+ while (prefix < maxPrefix && base.charCodeAt(prefix) === next.charCodeAt(prefix)) {
1806
+ prefix++;
1807
+ }
1808
+ let suffix = 0;
1809
+ const maxSuffix = Math.min(baseLen, nextLen) - prefix;
1810
+ while (suffix < maxSuffix && base.charCodeAt(baseLen - 1 - suffix) === next.charCodeAt(nextLen - 1 - suffix)) {
1811
+ suffix++;
1812
+ }
1813
+ const deleteCount = baseLen - prefix - suffix;
1814
+ const inserted = next.slice(prefix, nextLen - suffix);
1815
+ const ops = [];
1816
+ if (prefix > 0)
1817
+ ops.push({ retain: prefix });
1818
+ if (deleteCount > 0)
1819
+ ops.push({ delete: deleteCount });
1820
+ if (inserted.length > 0)
1821
+ ops.push({ insert: inserted });
1822
+ if (suffix > 0)
1823
+ ops.push({ retain: suffix });
1824
+ if (ops.length === 0)
1825
+ ops.push({ retain: baseLen });
1826
+ return ops;
1827
+ }
1828
+ function splitByBytes(payload, budgetBytes) {
1829
+ const parts = [];
1830
+ let current = "";
1831
+ let currentBytes = 0;
1832
+ for (const cp of payload) {
1833
+ const cpBytes = byteLength(cp);
1834
+ if (currentBytes + cpBytes > budgetBytes && current.length > 0) {
1835
+ parts.push(current);
1836
+ current = "";
1837
+ currentBytes = 0;
1838
+ }
1839
+ current += cp;
1840
+ currentBytes += cpBytes;
1841
+ }
1842
+ if (current.length > 0 || parts.length === 0)
1843
+ parts.push(current);
1844
+ return parts;
1845
+ }
1846
+ function chunkFrame(frame, budgetBytes = DEFAULT_CHUNK_BUDGET_BYTES) {
1847
+ if (frameByteLength(frame) <= budgetBytes)
1848
+ return [frame];
1849
+ const payload = frame.type === "key" ? frame.content : JSON.stringify(frame.ops);
1850
+ const dataBudget = Math.max(1, budgetBytes - 512);
1851
+ const pieces = splitByBytes(payload, dataBudget);
1852
+ return pieces.map((data, index) => {
1853
+ const chunk = {
1854
+ v: CODEC_VERSION,
1855
+ type: "chunk",
1856
+ seq: frame.seq,
1857
+ kind: frame.type,
1858
+ part: index,
1859
+ parts: pieces.length,
1860
+ data
1861
+ };
1862
+ if (frame.type === "patch")
1863
+ chunk.baseSeq = frame.baseSeq;
1864
+ return chunk;
1865
+ });
1866
+ }
1867
+ var StreamEncoder = class {
1868
+ keyframeInterval;
1869
+ keyframeIntervalMs;
1870
+ chunkBudgetBytes;
1871
+ now;
1872
+ seq = 0;
1873
+ prevContent = null;
1874
+ prevSeq = 0;
1875
+ framesSinceKey = 0;
1876
+ lastKeyAt = 0;
1877
+ constructor(options = {}) {
1878
+ this.keyframeInterval = options.keyframeInterval ?? DEFAULT_KEYFRAME_INTERVAL;
1879
+ this.keyframeIntervalMs = options.keyframeIntervalMs ?? DEFAULT_KEYFRAME_INTERVAL_MS;
1880
+ this.chunkBudgetBytes = options.chunkBudgetBytes ?? DEFAULT_CHUNK_BUDGET_BYTES;
1881
+ this.now = options.now ?? (() => Date.now());
1882
+ }
1883
+ /** Encode one snapshot of the artifact into wire frames. */
1884
+ encode(content) {
1885
+ const seq = ++this.seq;
1886
+ const now = this.now();
1887
+ const mustKeyframe = this.prevContent === null || this.framesSinceKey >= this.keyframeInterval || now - this.lastKeyAt >= this.keyframeIntervalMs;
1888
+ let frame;
1889
+ if (mustKeyframe) {
1890
+ frame = { v: CODEC_VERSION, type: "key", seq, content };
1891
+ this.framesSinceKey = 0;
1892
+ this.lastKeyAt = now;
1893
+ } else {
1894
+ frame = {
1895
+ v: CODEC_VERSION,
1896
+ type: "patch",
1897
+ seq,
1898
+ baseSeq: this.prevSeq,
1899
+ ops: diffStrings(this.prevContent, content)
1900
+ };
1901
+ this.framesSinceKey++;
1902
+ }
1903
+ this.prevContent = content;
1904
+ this.prevSeq = seq;
1905
+ return chunkFrame(frame, this.chunkBudgetBytes);
1906
+ }
1907
+ /** Reset to the initial state (e.g. a new draft on the same encoder). */
1908
+ reset() {
1909
+ this.seq = 0;
1910
+ this.prevContent = null;
1911
+ this.prevSeq = 0;
1912
+ this.framesSinceKey = 0;
1913
+ this.lastKeyAt = 0;
1914
+ }
1915
+ };
1791
1916
 
1792
1917
  // ../../packages/core/dist/integrations/oauth-providers.js
1793
1918
  var OAUTH_PROVIDERS = {
@@ -4755,6 +4880,7 @@ export {
4755
4880
  renderTemplate,
4756
4881
  DEPLOYMENT_TEMPLATES,
4757
4882
  getTemplate,
4883
+ StreamEncoder,
4758
4884
  worseConnectivityOutcome,
4759
4885
  resolveConnectivityProbe,
4760
4886
  probeComposioAccount,
@@ -4770,4 +4896,4 @@ export {
4770
4896
  attributeTranscriptUsageByRun,
4771
4897
  KANBAN_CHECK_COMMAND
4772
4898
  };
4773
- //# sourceMappingURL=chunk-WOOYOAPG.js.map
4899
+ //# sourceMappingURL=chunk-K5XUY6PS.js.map