stitchkit 0.118.1 → 0.119.0
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/CHANGELOG.md +66 -0
- package/dist/browser/http.d.ts.map +1 -1
- package/dist/contract/client-types.d.ts +6 -3
- package/dist/contract/client-types.d.ts.map +1 -1
- package/dist/contract/define-validation.d.ts.map +1 -1
- package/dist/contract/define.d.ts +18 -12
- package/dist/contract/define.d.ts.map +1 -1
- package/dist/contract/endpoint-capabilities.d.ts +28 -0
- package/dist/contract/endpoint-capabilities.d.ts.map +1 -0
- package/dist/contract/factory.d.ts +49 -19
- package/dist/contract/factory.d.ts.map +1 -1
- package/dist/contract/tool-view.d.ts +1 -1
- package/dist/contract/tool-view.d.ts.map +1 -1
- package/dist/contract/transports.d.ts +5 -0
- package/dist/contract/transports.d.ts.map +1 -0
- package/dist/entrypoints/agent-runtime/coding-tools.js +6 -5
- package/dist/entrypoints/agent-runtime/harness.js +6 -5
- package/dist/entrypoints/agent-runtime/sandbox.js +6 -5
- package/dist/entrypoints/agent-runtime/sqlite/bun.js +9 -8
- package/dist/entrypoints/agent-runtime/sqlite/node.js +9 -8
- package/dist/entrypoints/agent-runtime/testing.js +9 -8
- package/dist/entrypoints/agent-runtime.js +14 -13
- package/dist/entrypoints/application/diagnostic-journal.js +3 -3
- package/dist/entrypoints/application/directory-inbox.js +4 -4
- package/dist/entrypoints/application/opentelemetry.js +1 -1
- package/dist/entrypoints/application.js +5 -5
- package/dist/entrypoints/cli/publish.js +4 -4
- package/dist/entrypoints/cli.js +8 -7
- package/dist/entrypoints/contract.d.ts +1 -1
- package/dist/entrypoints/contract.d.ts.map +1 -1
- package/dist/entrypoints/contract.js +6 -4
- package/dist/entrypoints/files.js +3 -3
- package/dist/entrypoints/geo/contract.d.ts +7 -0
- package/dist/entrypoints/geo/contract.d.ts.map +1 -0
- package/dist/entrypoints/geo/contract.js +6 -0
- package/dist/entrypoints/geo.js +60 -23
- package/dist/entrypoints/http.js +2 -2
- package/dist/entrypoints/index.js +8 -6
- package/dist/entrypoints/live.js +1 -1
- package/dist/entrypoints/node.js +7 -6
- package/dist/entrypoints/primitives.js +1 -1
- package/dist/entrypoints/process/owner-loss.js +1 -1
- package/dist/entrypoints/process.js +3 -3
- package/dist/entrypoints/react.js +1 -1
- package/dist/entrypoints/remote.js +4 -3
- package/dist/entrypoints/server.js +11 -10
- package/dist/entrypoints/telegram.js +2 -2
- package/dist/entrypoints/testing.js +7 -6
- package/dist/entrypoints/tools/connections.js +3 -2
- package/dist/entrypoints/tools/contract.js +1 -1
- package/dist/entrypoints/tools/invoker.js +5 -4
- package/dist/entrypoints/tools/mcp.js +7 -6
- package/dist/entrypoints/tools.js +17 -15
- package/dist/entrypoints/tracking/contract.js +5 -3
- package/dist/entrypoints/tracking/performance.js +3 -3
- package/dist/entrypoints/tracking.d.ts +1 -1
- package/dist/entrypoints/tracking.d.ts.map +1 -1
- package/dist/entrypoints/tracking.js +63 -83
- package/dist/entrypoints/xlsx.js +1 -1
- package/dist/geo/index.d.ts +2 -1
- package/dist/geo/index.d.ts.map +1 -1
- package/dist/geo/record.d.ts +8 -0
- package/dist/geo/record.d.ts.map +1 -0
- package/dist/geo/resolver.d.ts +1 -3
- package/dist/geo/resolver.d.ts.map +1 -1
- package/dist/geo/schema.d.ts +44 -0
- package/dist/geo/schema.d.ts.map +1 -0
- package/dist/geo/types.d.ts +2 -13
- package/dist/geo/types.d.ts.map +1 -1
- package/dist/{index-n5sv4z0w.js → index-1k18qzqa.js} +13 -15
- package/dist/{index-tsngj2b5.js → index-2dfvv1jg.js} +206 -206
- package/dist/{index-d9hq291n.js → index-4jpykzvw.js} +70 -81
- package/dist/{index-ghtpfz4z.js → index-57gqaq8b.js} +2 -2
- package/dist/index-69t14s4a.js +39 -0
- package/dist/{index-6p3frkv5.js → index-6a69xzrx.js} +4 -4
- package/dist/{index-dky0dcmf.js → index-72r9k0av.js} +6 -2
- package/dist/{index-vv1sch8a.js → index-8vzh5wpv.js} +13 -8
- package/dist/{index-xx1j310k.js → index-8yxgcyt6.js} +171 -169
- package/dist/{index-p6apg0jg.js → index-9frf01t9.js} +16 -9
- package/dist/{index-q0th8q0z.js → index-9mjrnqxs.js} +1 -3
- package/dist/{index-ega3yz4c.js → index-aqwg2dm5.js} +1 -1
- package/dist/{index-073nw9qr.js → index-ba7are04.js} +524 -522
- package/dist/{index-095ya5hm.js → index-bbvc59gw.js} +13 -11
- package/dist/{index-txg1npmg.js → index-cyxp8rbf.js} +1 -1
- package/dist/index-d3xdyjt6.js +38 -0
- package/dist/{index-n8z3rvzw.js → index-f4njz9j0.js} +3 -5
- package/dist/{index-90p34rts.js → index-fcqj44mb.js} +3 -1
- package/dist/{index-86nbfysb.js → index-ff39f9dr.js} +3 -3
- package/dist/{index-75ns2ybj.js → index-fqd4yqwd.js} +1 -1
- package/dist/{index-nqxrm176.js → index-g444vfz2.js} +1 -1
- package/dist/{index-vwhrnp67.js → index-kz9734jc.js} +3 -3
- package/dist/{index-dr3t5n1v.js → index-nn9qvkww.js} +46 -46
- package/dist/{index-qezhmp51.js → index-nz06qw5a.js} +3 -1
- package/dist/{index-1bx1xv1k.js → index-pfvde2fz.js} +5 -2
- package/dist/{index-s80awwsw.js → index-qch1vcaa.js} +3 -1
- package/dist/{index-cycp3r3e.js → index-rxcgp4b9.js} +2 -2
- package/dist/{index-w7jq3fz9.js → index-s0qjs6ee.js} +1198 -1196
- package/dist/{index-p0rf7sq9.js → index-s20s2mad.js} +209 -209
- package/dist/{index-v6vb5qx8.js → index-s3yxw6kt.js} +1 -1
- package/dist/{index-cqmqyjax.js → index-sa99p98w.js} +1 -1
- package/dist/{index-0gxvns6s.js → index-sba3e6m4.js} +1 -0
- package/dist/{index-f24bdt13.js → index-v1swr26p.js} +3 -1
- package/dist/{index-rhzkndr5.js → index-x4p3kw1p.js} +533 -530
- package/dist/{index-hdjmdwsj.js → index-x8d9fdeg.js} +513 -507
- package/dist/{index-htxh46ej.js → index-ycqhyars.js} +2 -2
- package/dist/{index-9bwcthxw.js → index-yj6saztf.js} +31 -13
- package/dist/{index-tdpmfks8.js → index-ynrf908v.js} +1 -1
- package/dist/{index-f6m4c545.js → index-zrdcmg6j.js} +4 -6
- package/dist/process/bun-child.d.ts +3 -2
- package/dist/process/bun-child.d.ts.map +1 -1
- package/dist/server/contract-method.d.ts.map +1 -1
- package/dist/tools/internal/surface-projector.d.ts.map +1 -1
- package/dist/tools/operations/async-operation-canonical-types.d.ts +1 -1
- package/dist/tracking/attribution.d.ts +21 -25
- package/dist/tracking/attribution.d.ts.map +1 -1
- package/dist/tracking/client-visit.d.ts +5 -7
- package/dist/tracking/client-visit.d.ts.map +1 -1
- package/dist/tracking/client.d.ts +2 -2
- package/dist/tracking/client.d.ts.map +1 -1
- package/dist/tracking/contract.d.ts +1 -1
- package/dist/tracking/host.d.ts +0 -1
- package/dist/tracking/host.d.ts.map +1 -1
- package/dist/tracking/privacy.d.ts +6 -0
- package/dist/tracking/privacy.d.ts.map +1 -1
- package/dist/tracking/schemas.d.ts +2 -2
- package/dist/tracking/schemas.d.ts.map +1 -1
- package/llms/contract.txt +46 -24
- package/llms/geo-contract.txt +23 -0
- package/llms/geo.txt +40 -4
- package/llms/stitchkit.txt +4 -3
- package/llms/tools.2.txt +2 -2
- package/llms/tools.3.txt +1 -1
- package/llms/tracking-contract.txt +1 -1
- package/llms/tracking.txt +27 -5
- package/llms/{upgrading-0.105.0-0.118.0.txt → upgrading-0.106.0-0.119.0.txt} +121 -410
- package/llms/upgrading-0.37.0-0.53.0.txt +969 -0
- package/llms/{upgrading-0.44.0-0.62.0.txt → upgrading-0.55.0-0.68.0.txt} +509 -528
- package/llms/{upgrading-0.63.0-0.83.0.txt → upgrading-0.69.0-0.95.0.txt} +506 -509
- package/llms/{upgrading-0.84.0-0.104.0.txt → upgrading-0.96.0-0.105.0.txt} +410 -506
- package/llms/upgrading.txt +5 -5
- package/llms-full.txt +247 -38
- package/llms.txt +10 -9
- package/package.json +23 -19
- package/llms/upgrading-0.37.0-0.44.0.txt +0 -444
package/dist/entrypoints/xlsx.js
CHANGED
package/dist/geo/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export { createMaxMindGeoIpLoader } from './maxmind.js';
|
|
2
|
-
export {
|
|
2
|
+
export { mapGeoIpRecord } from './record.js';
|
|
3
|
+
export { createGeoIpResolver } from './resolver.js';
|
|
3
4
|
export type { GeoAttribution, GeoIpReader, GeoIpReaderLoader, GeoIpResolver, GeoIpResolverOptions, GeoIpSnapshot, MaxMindGeoIpLoaderOptions, MaxMindGeoIpPaths, } from './types.js';
|
|
4
5
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/geo/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/geo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/geo/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC1C,OAAO,EAAE,mBAAmB,EAAE,MAAM,YAAY,CAAC;AACjD,YAAY,EACV,cAAc,EACd,WAAW,EACX,iBAAiB,EACjB,aAAa,EACb,oBAAoB,EACpB,aAAa,EACb,yBAAyB,EACzB,iBAAiB,GAClB,MAAM,SAAS,CAAC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type GeoAttribution } from './schema.js';
|
|
2
|
+
/**
|
|
3
|
+
* Map a City + ASN record to the complete sparse snapshot without exposing
|
|
4
|
+
* optional-peer types. Each field is validated by the schema on its own, so a
|
|
5
|
+
* malformed value drops that field and keeps the rest.
|
|
6
|
+
*/
|
|
7
|
+
export declare function mapGeoIpRecord(value: unknown): GeoAttribution | null;
|
|
8
|
+
//# sourceMappingURL=record.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../src/geo/record.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,cAAc,EAAuC,MAAM,UAAU,CAAC;AAkCpF;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,cAAc,GAAG,IAAI,CAsDpE"}
|
package/dist/geo/resolver.d.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
/** Map the common MaxMind record shape without exposing peer types. */
|
|
3
|
-
export declare function mapGeoIpRecord(value: unknown): GeoAttribution | null;
|
|
1
|
+
import type { GeoIpResolver, GeoIpResolverOptions } from './types.js';
|
|
4
2
|
/**
|
|
5
3
|
* Create a server-only GeoIP managed resource with atomic generation swaps.
|
|
6
4
|
* Initial absence is non-fatal; reload failure preserves the last good reader.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/geo/resolver.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../../src/geo/resolver.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAe,aAAa,EAAE,oBAAoB,EAAiB,MAAM,SAAS,CAAC;AAc/F;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EACxC,OAAO,EAAE,oBAAoB,CAAC,MAAM,CAAC,GACpC,aAAa,CAyHf"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
/** A label as the GeoIP database spells it; an empty string is no label. */
|
|
3
|
+
export declare const GeoTextSchema: z.ZodString;
|
|
4
|
+
/** GeoNames IDs and the accuracy radius: whole, nonnegative and exact. */
|
|
5
|
+
export declare const GeoNonnegativeIntegerSchema: z.ZodNumber;
|
|
6
|
+
/** One place's names by locale code, every language the database carries. */
|
|
7
|
+
export declare const GeoLocalizedNamesSchema: z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>;
|
|
8
|
+
/**
|
|
9
|
+
* Where an IP address is, as a GeoLite2 / GeoIP2 City and ASN record says it.
|
|
10
|
+
* Every field is optional: a record states what it knows. The located country
|
|
11
|
+
* and the country the address block is registered to are separate facts.
|
|
12
|
+
*/
|
|
13
|
+
export declare const GeoAttributionSchema: z.ZodReadonly<z.ZodObject<{
|
|
14
|
+
continentCode: z.ZodOptional<z.ZodString>;
|
|
15
|
+
continentName: z.ZodOptional<z.ZodString>;
|
|
16
|
+
continentGeonameId: z.ZodOptional<z.ZodNumber>;
|
|
17
|
+
countryCode: z.ZodOptional<z.ZodString>;
|
|
18
|
+
countryName: z.ZodOptional<z.ZodString>;
|
|
19
|
+
countryGeonameId: z.ZodOptional<z.ZodNumber>;
|
|
20
|
+
registeredCountryCode: z.ZodOptional<z.ZodString>;
|
|
21
|
+
registeredCountryName: z.ZodOptional<z.ZodString>;
|
|
22
|
+
registeredCountryGeonameId: z.ZodOptional<z.ZodNumber>;
|
|
23
|
+
regionCode: z.ZodOptional<z.ZodString>;
|
|
24
|
+
regionName: z.ZodOptional<z.ZodString>;
|
|
25
|
+
regionGeonameId: z.ZodOptional<z.ZodNumber>;
|
|
26
|
+
city: z.ZodOptional<z.ZodString>;
|
|
27
|
+
cityGeonameId: z.ZodOptional<z.ZodNumber>;
|
|
28
|
+
postalCode: z.ZodOptional<z.ZodString>;
|
|
29
|
+
latitude: z.ZodOptional<z.ZodNumber>;
|
|
30
|
+
longitude: z.ZodOptional<z.ZodNumber>;
|
|
31
|
+
timezone: z.ZodOptional<z.ZodString>;
|
|
32
|
+
accuracyRadiusKm: z.ZodOptional<z.ZodNumber>;
|
|
33
|
+
autonomousSystemNumber: z.ZodOptional<z.ZodNumber>;
|
|
34
|
+
autonomousSystemOrganization: z.ZodOptional<z.ZodString>;
|
|
35
|
+
localizedNames: z.ZodOptional<z.ZodReadonly<z.ZodObject<{
|
|
36
|
+
continent: z.ZodOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
37
|
+
country: z.ZodOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
38
|
+
registeredCountry: z.ZodOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
39
|
+
region: z.ZodOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
40
|
+
city: z.ZodOptional<z.ZodReadonly<z.ZodRecord<z.ZodString, z.ZodString>>>;
|
|
41
|
+
}, z.core.$strict>>>;
|
|
42
|
+
}, z.core.$strict>>;
|
|
43
|
+
export type GeoAttribution = z.infer<typeof GeoAttributionSchema>;
|
|
44
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/geo/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,4EAA4E;AAC5E,eAAO,MAAM,aAAa,aAAoB,CAAC;AAC/C,0EAA0E;AAC1E,eAAO,MAAM,2BAA2B,aAAiC,CAAC;AAC1E,6EAA6E;AAC7E,eAAO,MAAM,uBAAuB,sDAAoD,CAAC;AAYzF;;;;GAIG;AACH,eAAO,MAAM,oBAAoB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;mBAyBpB,CAAC;AACd,MAAM,MAAM,cAAc,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oBAAoB,CAAC,CAAC"}
|
package/dist/geo/types.d.ts
CHANGED
|
@@ -1,17 +1,6 @@
|
|
|
1
1
|
import type { ManagedResource, ManagedResourceContext } from '../application/resource.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
readonly countryName?: string;
|
|
5
|
-
readonly regionCode?: string;
|
|
6
|
-
readonly regionName?: string;
|
|
7
|
-
readonly city?: string;
|
|
8
|
-
readonly postalCode?: string;
|
|
9
|
-
readonly latitude?: number;
|
|
10
|
-
readonly longitude?: number;
|
|
11
|
-
readonly timezone?: string;
|
|
12
|
-
readonly autonomousSystemNumber?: number;
|
|
13
|
-
readonly autonomousSystemOrganization?: string;
|
|
14
|
-
}
|
|
2
|
+
import type { GeoAttribution } from './schema.js';
|
|
3
|
+
export type { GeoAttribution } from './schema.js';
|
|
15
4
|
export interface MaxMindGeoIpPaths {
|
|
16
5
|
readonly city: string;
|
|
17
6
|
readonly asn?: string;
|
package/dist/geo/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/geo/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/geo/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,sBAAsB,EAAE,MAAM,yBAAyB,CAAC;AACvF,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE/C,MAAM,WAAW,iBAAiB;IAChC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,GAAG,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,yBAAyB;IACxC,sEAAsE;IACtE,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,CAAC;CAC5C;AAED,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;IAC/C,KAAK,CAAC,IAAI,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;CAChC;AAED,6EAA6E;AAC7E,MAAM,WAAW,iBAAiB,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC1E,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAChE,iFAAiF;IACjF,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,gBAAgB,EAAE,MAAM,GAAG,WAAW,GAAG,OAAO,CAAC,WAAW,CAAC,CAAC;CACnF;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,KAAK,EAAE,eAAe,GAAG,aAAa,GAAG,OAAO,CAAC;IAC1D,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,4EAA4E;IAC5E,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,aAAc,SAAQ,eAAe;IACpD,KAAK,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC;QAAE,KAAK,EAAE,aAAa,CAAA;KAAE,CAAC,CAAC;IAC1E,OAAO,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC,CAAC;IACpD,MAAM,IAAI,OAAO,CAAC,OAAO,CAAC,CAAC;IAC3B,QAAQ,IAAI,aAAa,CAAC;CAC3B;AAED,MAAM,WAAW,oBAAoB,CAAC,MAAM,GAAG,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC7E,QAAQ,CAAC,EAAE,CAAC,EAAE,MAAM,CAAC;IACrB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC,MAAM,CAAC,CAAC;IAC3C,QAAQ,CAAC,MAAM,CAAC,EAAE,KAAK,GAAG;QAAE,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAA;KAAE,CAAC;IAC3D,QAAQ,CAAC,GAAG,CAAC,EAAE,CAAC,MAAM,EAAE,OAAO,KAAK,cAAc,GAAG,IAAI,CAAC;IAC1D,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,MAAM,CAAC;IAC9B,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CAC7C"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import {
|
|
2
2
|
NativeCommandError2
|
|
3
|
-
} from "./index-
|
|
3
|
+
} from "./index-zrdcmg6j.js";
|
|
4
4
|
import {
|
|
5
5
|
CommandStopped,
|
|
6
6
|
startNativeCommand
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-nn9qvkww.js";
|
|
8
8
|
import {
|
|
9
9
|
scanContainedFiles
|
|
10
10
|
} from "./index-6f49krb5.js";
|
|
@@ -27,7 +27,7 @@ import {
|
|
|
27
27
|
} from "./index-arjmb6de.js";
|
|
28
28
|
import {
|
|
29
29
|
defineRuntimeTool2
|
|
30
|
-
} from "./index-
|
|
30
|
+
} from "./index-aqwg2dm5.js";
|
|
31
31
|
import {
|
|
32
32
|
errnoOf
|
|
33
33
|
} from "./index-jj9228tt.js";
|
|
@@ -252,18 +252,6 @@ async function recordAgentSandboxProbe2(input) {
|
|
|
252
252
|
return grade;
|
|
253
253
|
}
|
|
254
254
|
|
|
255
|
-
// src/agent-runtime/coding-tools.ts
|
|
256
|
-
import path4 from "node:path";
|
|
257
|
-
import { z as z5 } from "zod";
|
|
258
|
-
|
|
259
|
-
// src/agent-runtime/coding-tool-files.ts
|
|
260
|
-
import { createHash } from "node:crypto";
|
|
261
|
-
import { realpath as realpath2 } from "node:fs/promises";
|
|
262
|
-
|
|
263
|
-
// src/agent-runtime/coding-tool-paths.ts
|
|
264
|
-
import { lstat, realpath } from "node:fs/promises";
|
|
265
|
-
import path from "node:path";
|
|
266
|
-
|
|
267
255
|
// src/agent-runtime/coding-tool-refusals.ts
|
|
268
256
|
function codingRefusal(code, message, options = {}) {
|
|
269
257
|
throw new AppError2(code, {
|
|
@@ -359,7 +347,17 @@ function refuseUnknownSpillReference(reference) {
|
|
|
359
347
|
});
|
|
360
348
|
}
|
|
361
349
|
|
|
350
|
+
// src/agent-runtime/coding-tools.ts
|
|
351
|
+
import path4 from "node:path";
|
|
352
|
+
import { z as z5 } from "zod";
|
|
353
|
+
|
|
354
|
+
// src/agent-runtime/coding-tool-files.ts
|
|
355
|
+
import { createHash } from "node:crypto";
|
|
356
|
+
import { realpath as realpath2 } from "node:fs/promises";
|
|
357
|
+
|
|
362
358
|
// src/agent-runtime/coding-tool-paths.ts
|
|
359
|
+
import { lstat, realpath } from "node:fs/promises";
|
|
360
|
+
import path from "node:path";
|
|
363
361
|
function within(root, target) {
|
|
364
362
|
const relative = path.relative(root, target);
|
|
365
363
|
return relative === "" || !relative.startsWith(`..${path.sep}`) && relative !== ".." && !path.isAbsolute(relative);
|
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
uploadProgressRoute,
|
|
14
14
|
withUploadProgress,
|
|
15
15
|
parseApiErrorBody
|
|
16
|
-
} from "./index-
|
|
16
|
+
} from "./index-9frf01t9.js";
|
|
17
17
|
import {
|
|
18
18
|
inputIsQuery
|
|
19
19
|
} from "./index-xhzq2qvj.js";
|
|
@@ -33,211 +33,6 @@ import {
|
|
|
33
33
|
mapObject
|
|
34
34
|
} from "./index-9jfdm5tg.js";
|
|
35
35
|
|
|
36
|
-
// src/internal/bounded-lines.ts
|
|
37
|
-
var DEFAULT_STREAM_LINE_BYTES = 1024 * 1024;
|
|
38
|
-
|
|
39
|
-
class StreamLineLimitError2 extends RangeError {
|
|
40
|
-
limitBytes;
|
|
41
|
-
lineBytes;
|
|
42
|
-
name = "StreamLineLimitError";
|
|
43
|
-
constructor(limitBytes, lineBytes) {
|
|
44
|
-
super(`Stream line exceeds the ${limitBytes} byte limit (${lineBytes} bytes so far)`);
|
|
45
|
-
this.limitBytes = limitBytes;
|
|
46
|
-
this.lineBytes = lineBytes;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
class StreamTruncatedLineError2 extends SyntaxError {
|
|
51
|
-
lineBytes;
|
|
52
|
-
name = "StreamTruncatedLineError";
|
|
53
|
-
constructor(lineBytes) {
|
|
54
|
-
super(`Stream ended with an unterminated final line (${lineBytes} bytes)`);
|
|
55
|
-
this.lineBytes = lineBytes;
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function lineLimit(value) {
|
|
59
|
-
const resolved = value ?? DEFAULT_STREAM_LINE_BYTES;
|
|
60
|
-
assertPositiveSafeInteger("maxLineBytes", resolved);
|
|
61
|
-
return resolved;
|
|
62
|
-
}
|
|
63
|
-
function createLineSplitter(maxLineBytes, requireFinalNewline = false) {
|
|
64
|
-
const limit = lineLimit(maxLineBytes);
|
|
65
|
-
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
66
|
-
let parts = [];
|
|
67
|
-
let pendingBytes = 0;
|
|
68
|
-
let ended = false;
|
|
69
|
-
let failed = false;
|
|
70
|
-
const drop = () => {
|
|
71
|
-
parts = [];
|
|
72
|
-
pendingBytes = 0;
|
|
73
|
-
};
|
|
74
|
-
const retain = (bytes) => {
|
|
75
|
-
if (bytes.byteLength === 0)
|
|
76
|
-
return;
|
|
77
|
-
pendingBytes += bytes.byteLength;
|
|
78
|
-
if (pendingBytes > limit) {
|
|
79
|
-
const seen = pendingBytes;
|
|
80
|
-
drop();
|
|
81
|
-
throw new StreamLineLimitError2(limit, seen);
|
|
82
|
-
}
|
|
83
|
-
parts.push(new Uint8Array(bytes));
|
|
84
|
-
};
|
|
85
|
-
const take = () => {
|
|
86
|
-
const line = new Uint8Array(pendingBytes);
|
|
87
|
-
let at = 0;
|
|
88
|
-
for (const part of parts) {
|
|
89
|
-
line.set(part, at);
|
|
90
|
-
at += part.byteLength;
|
|
91
|
-
}
|
|
92
|
-
drop();
|
|
93
|
-
return decoder.decode(line);
|
|
94
|
-
};
|
|
95
|
-
function* lines(chunk) {
|
|
96
|
-
if (ended)
|
|
97
|
-
throw new Error("Line decoder received bytes after end()");
|
|
98
|
-
if (failed)
|
|
99
|
-
throw new Error("Line decoder stopped at an earlier error; read the source again");
|
|
100
|
-
try {
|
|
101
|
-
let start = 0;
|
|
102
|
-
for (let index = chunk.indexOf(10);index !== -1; index = chunk.indexOf(10, start)) {
|
|
103
|
-
retain(chunk.subarray(start, index));
|
|
104
|
-
yield take();
|
|
105
|
-
start = index + 1;
|
|
106
|
-
}
|
|
107
|
-
retain(chunk.subarray(start));
|
|
108
|
-
} catch (error) {
|
|
109
|
-
failed = true;
|
|
110
|
-
throw error;
|
|
111
|
-
}
|
|
112
|
-
}
|
|
113
|
-
return {
|
|
114
|
-
lines,
|
|
115
|
-
push: (chunk) => [...lines(chunk)],
|
|
116
|
-
end() {
|
|
117
|
-
ended = true;
|
|
118
|
-
if (pendingBytes === 0)
|
|
119
|
-
return [];
|
|
120
|
-
if (requireFinalNewline) {
|
|
121
|
-
const seen = pendingBytes;
|
|
122
|
-
drop();
|
|
123
|
-
throw new StreamTruncatedLineError2(seen);
|
|
124
|
-
}
|
|
125
|
-
return [take()];
|
|
126
|
-
}
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
function createBoundedLineDecoder(maxLineBytes, requireFinalNewline = false) {
|
|
130
|
-
const { push, end } = createLineSplitter(maxLineBytes, requireFinalNewline);
|
|
131
|
-
return { push, end };
|
|
132
|
-
}
|
|
133
|
-
async function* readBoundedUtf8Lines(source, maxLineBytes, requireFinalNewline = false, signal) {
|
|
134
|
-
const splitter = createLineSplitter(maxLineBytes, requireFinalNewline);
|
|
135
|
-
for await (const chunk of chunksOf(source, signal)) {
|
|
136
|
-
for (const line of splitter.lines(chunk)) {
|
|
137
|
-
signal?.throwIfAborted();
|
|
138
|
-
yield line;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
for (const line of splitter.end()) {
|
|
142
|
-
signal?.throwIfAborted();
|
|
143
|
-
yield line;
|
|
144
|
-
}
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
// src/browser/stream.ts
|
|
148
|
-
function ndjsonLine(rawLine) {
|
|
149
|
-
return (rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine).trim();
|
|
150
|
-
}
|
|
151
|
-
function parseFailure(raw, error, onParseError) {
|
|
152
|
-
const failure = error instanceof Error ? error : new Error(String(error));
|
|
153
|
-
if (!onParseError)
|
|
154
|
-
throw failure;
|
|
155
|
-
onParseError(raw, failure);
|
|
156
|
-
}
|
|
157
|
-
async function* parseNDJSON2(source, options) {
|
|
158
|
-
let reporting = false;
|
|
159
|
-
try {
|
|
160
|
-
for await (const rawLine of readBoundedUtf8Lines(source, options?.maxLineBytes ?? DEFAULT_STREAM_LINE_BYTES, options?.finalLine === "require-newline", options?.signal)) {
|
|
161
|
-
const line = ndjsonLine(rawLine);
|
|
162
|
-
if (line === "")
|
|
163
|
-
continue;
|
|
164
|
-
let value;
|
|
165
|
-
try {
|
|
166
|
-
value = JSON.parse(line);
|
|
167
|
-
} catch (error) {
|
|
168
|
-
reporting = true;
|
|
169
|
-
parseFailure(line, error, options?.onParseError);
|
|
170
|
-
reporting = false;
|
|
171
|
-
continue;
|
|
172
|
-
}
|
|
173
|
-
yield value;
|
|
174
|
-
}
|
|
175
|
-
} catch (error) {
|
|
176
|
-
if (reporting || options?.signal?.aborted)
|
|
177
|
-
throw error;
|
|
178
|
-
parseFailure("", error, options?.onParseError);
|
|
179
|
-
}
|
|
180
|
-
}
|
|
181
|
-
function createNDJSONDecoder2(options) {
|
|
182
|
-
const lines = createBoundedLineDecoder(options?.maxLineBytes ?? DEFAULT_STREAM_LINE_BYTES, options?.finalLine === "require-newline");
|
|
183
|
-
let failed = false;
|
|
184
|
-
const values = (rawLines) => {
|
|
185
|
-
const parsed = [];
|
|
186
|
-
for (const rawLine of rawLines) {
|
|
187
|
-
const line = ndjsonLine(rawLine);
|
|
188
|
-
if (line === "")
|
|
189
|
-
continue;
|
|
190
|
-
try {
|
|
191
|
-
parsed.push(JSON.parse(line));
|
|
192
|
-
} catch (error) {
|
|
193
|
-
parseFailure(line, error, options?.onParseError);
|
|
194
|
-
}
|
|
195
|
-
}
|
|
196
|
-
return parsed;
|
|
197
|
-
};
|
|
198
|
-
const guarded = (step) => {
|
|
199
|
-
if (failed)
|
|
200
|
-
throw new Error("NDJSON decoder stopped at an earlier error; read the source again");
|
|
201
|
-
try {
|
|
202
|
-
return values(step());
|
|
203
|
-
} catch (error) {
|
|
204
|
-
failed = true;
|
|
205
|
-
throw error;
|
|
206
|
-
}
|
|
207
|
-
};
|
|
208
|
-
return {
|
|
209
|
-
push: (chunk) => guarded(() => lines.push(chunk)),
|
|
210
|
-
end: () => guarded(() => lines.end())
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
async function* parseSSE2(source, options) {
|
|
214
|
-
let reporting = false;
|
|
215
|
-
try {
|
|
216
|
-
for await (const rawLine of readBoundedUtf8Lines(source, options?.maxLineBytes ?? DEFAULT_STREAM_LINE_BYTES, false, options?.signal)) {
|
|
217
|
-
const line = rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine;
|
|
218
|
-
if (!line.startsWith("data:"))
|
|
219
|
-
continue;
|
|
220
|
-
const data = line.slice(5).replace(/^ /, "");
|
|
221
|
-
if (data === "[DONE]")
|
|
222
|
-
return;
|
|
223
|
-
let value;
|
|
224
|
-
try {
|
|
225
|
-
value = JSON.parse(data);
|
|
226
|
-
} catch (error) {
|
|
227
|
-
reporting = true;
|
|
228
|
-
parseFailure(data, error, options?.onParseError);
|
|
229
|
-
reporting = false;
|
|
230
|
-
continue;
|
|
231
|
-
}
|
|
232
|
-
yield value;
|
|
233
|
-
}
|
|
234
|
-
} catch (error) {
|
|
235
|
-
if (reporting || options?.signal?.aborted)
|
|
236
|
-
throw error;
|
|
237
|
-
parseFailure("", error, options?.onParseError);
|
|
238
|
-
}
|
|
239
|
-
}
|
|
240
|
-
|
|
241
36
|
// src/browser/client-arguments.ts
|
|
242
37
|
function endpointHasArguments(endpoint) {
|
|
243
38
|
return Boolean(endpoint.params || endpoint.input || endpoint.multipart);
|
|
@@ -464,6 +259,211 @@ function joinClientBaseUrl(baseUrl, relativeUrl) {
|
|
|
464
259
|
return `${base}${path}`;
|
|
465
260
|
}
|
|
466
261
|
|
|
262
|
+
// src/internal/bounded-lines.ts
|
|
263
|
+
var DEFAULT_STREAM_LINE_BYTES = 1024 * 1024;
|
|
264
|
+
|
|
265
|
+
class StreamLineLimitError2 extends RangeError {
|
|
266
|
+
limitBytes;
|
|
267
|
+
lineBytes;
|
|
268
|
+
name = "StreamLineLimitError";
|
|
269
|
+
constructor(limitBytes, lineBytes) {
|
|
270
|
+
super(`Stream line exceeds the ${limitBytes} byte limit (${lineBytes} bytes so far)`);
|
|
271
|
+
this.limitBytes = limitBytes;
|
|
272
|
+
this.lineBytes = lineBytes;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
class StreamTruncatedLineError2 extends SyntaxError {
|
|
277
|
+
lineBytes;
|
|
278
|
+
name = "StreamTruncatedLineError";
|
|
279
|
+
constructor(lineBytes) {
|
|
280
|
+
super(`Stream ended with an unterminated final line (${lineBytes} bytes)`);
|
|
281
|
+
this.lineBytes = lineBytes;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
function lineLimit(value) {
|
|
285
|
+
const resolved = value ?? DEFAULT_STREAM_LINE_BYTES;
|
|
286
|
+
assertPositiveSafeInteger("maxLineBytes", resolved);
|
|
287
|
+
return resolved;
|
|
288
|
+
}
|
|
289
|
+
function createLineSplitter(maxLineBytes, requireFinalNewline = false) {
|
|
290
|
+
const limit = lineLimit(maxLineBytes);
|
|
291
|
+
const decoder = new TextDecoder("utf-8", { fatal: true });
|
|
292
|
+
let parts = [];
|
|
293
|
+
let pendingBytes = 0;
|
|
294
|
+
let ended = false;
|
|
295
|
+
let failed = false;
|
|
296
|
+
const drop = () => {
|
|
297
|
+
parts = [];
|
|
298
|
+
pendingBytes = 0;
|
|
299
|
+
};
|
|
300
|
+
const retain = (bytes) => {
|
|
301
|
+
if (bytes.byteLength === 0)
|
|
302
|
+
return;
|
|
303
|
+
pendingBytes += bytes.byteLength;
|
|
304
|
+
if (pendingBytes > limit) {
|
|
305
|
+
const seen = pendingBytes;
|
|
306
|
+
drop();
|
|
307
|
+
throw new StreamLineLimitError2(limit, seen);
|
|
308
|
+
}
|
|
309
|
+
parts.push(new Uint8Array(bytes));
|
|
310
|
+
};
|
|
311
|
+
const take = () => {
|
|
312
|
+
const line = new Uint8Array(pendingBytes);
|
|
313
|
+
let at = 0;
|
|
314
|
+
for (const part of parts) {
|
|
315
|
+
line.set(part, at);
|
|
316
|
+
at += part.byteLength;
|
|
317
|
+
}
|
|
318
|
+
drop();
|
|
319
|
+
return decoder.decode(line);
|
|
320
|
+
};
|
|
321
|
+
function* lines(chunk) {
|
|
322
|
+
if (ended)
|
|
323
|
+
throw new Error("Line decoder received bytes after end()");
|
|
324
|
+
if (failed)
|
|
325
|
+
throw new Error("Line decoder stopped at an earlier error; read the source again");
|
|
326
|
+
try {
|
|
327
|
+
let start = 0;
|
|
328
|
+
for (let index = chunk.indexOf(10);index !== -1; index = chunk.indexOf(10, start)) {
|
|
329
|
+
retain(chunk.subarray(start, index));
|
|
330
|
+
yield take();
|
|
331
|
+
start = index + 1;
|
|
332
|
+
}
|
|
333
|
+
retain(chunk.subarray(start));
|
|
334
|
+
} catch (error) {
|
|
335
|
+
failed = true;
|
|
336
|
+
throw error;
|
|
337
|
+
}
|
|
338
|
+
}
|
|
339
|
+
return {
|
|
340
|
+
lines,
|
|
341
|
+
push: (chunk) => [...lines(chunk)],
|
|
342
|
+
end() {
|
|
343
|
+
ended = true;
|
|
344
|
+
if (pendingBytes === 0)
|
|
345
|
+
return [];
|
|
346
|
+
if (requireFinalNewline) {
|
|
347
|
+
const seen = pendingBytes;
|
|
348
|
+
drop();
|
|
349
|
+
throw new StreamTruncatedLineError2(seen);
|
|
350
|
+
}
|
|
351
|
+
return [take()];
|
|
352
|
+
}
|
|
353
|
+
};
|
|
354
|
+
}
|
|
355
|
+
function createBoundedLineDecoder(maxLineBytes, requireFinalNewline = false) {
|
|
356
|
+
const { push, end } = createLineSplitter(maxLineBytes, requireFinalNewline);
|
|
357
|
+
return { push, end };
|
|
358
|
+
}
|
|
359
|
+
async function* readBoundedUtf8Lines(source, maxLineBytes, requireFinalNewline = false, signal) {
|
|
360
|
+
const splitter = createLineSplitter(maxLineBytes, requireFinalNewline);
|
|
361
|
+
for await (const chunk of chunksOf(source, signal)) {
|
|
362
|
+
for (const line of splitter.lines(chunk)) {
|
|
363
|
+
signal?.throwIfAborted();
|
|
364
|
+
yield line;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
for (const line of splitter.end()) {
|
|
368
|
+
signal?.throwIfAborted();
|
|
369
|
+
yield line;
|
|
370
|
+
}
|
|
371
|
+
}
|
|
372
|
+
|
|
373
|
+
// src/browser/stream.ts
|
|
374
|
+
function ndjsonLine(rawLine) {
|
|
375
|
+
return (rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine).trim();
|
|
376
|
+
}
|
|
377
|
+
function parseFailure(raw, error, onParseError) {
|
|
378
|
+
const failure = error instanceof Error ? error : new Error(String(error));
|
|
379
|
+
if (!onParseError)
|
|
380
|
+
throw failure;
|
|
381
|
+
onParseError(raw, failure);
|
|
382
|
+
}
|
|
383
|
+
async function* parseNDJSON2(source, options) {
|
|
384
|
+
let reporting = false;
|
|
385
|
+
try {
|
|
386
|
+
for await (const rawLine of readBoundedUtf8Lines(source, options?.maxLineBytes ?? DEFAULT_STREAM_LINE_BYTES, options?.finalLine === "require-newline", options?.signal)) {
|
|
387
|
+
const line = ndjsonLine(rawLine);
|
|
388
|
+
if (line === "")
|
|
389
|
+
continue;
|
|
390
|
+
let value;
|
|
391
|
+
try {
|
|
392
|
+
value = JSON.parse(line);
|
|
393
|
+
} catch (error) {
|
|
394
|
+
reporting = true;
|
|
395
|
+
parseFailure(line, error, options?.onParseError);
|
|
396
|
+
reporting = false;
|
|
397
|
+
continue;
|
|
398
|
+
}
|
|
399
|
+
yield value;
|
|
400
|
+
}
|
|
401
|
+
} catch (error) {
|
|
402
|
+
if (reporting || options?.signal?.aborted)
|
|
403
|
+
throw error;
|
|
404
|
+
parseFailure("", error, options?.onParseError);
|
|
405
|
+
}
|
|
406
|
+
}
|
|
407
|
+
function createNDJSONDecoder2(options) {
|
|
408
|
+
const lines = createBoundedLineDecoder(options?.maxLineBytes ?? DEFAULT_STREAM_LINE_BYTES, options?.finalLine === "require-newline");
|
|
409
|
+
let failed = false;
|
|
410
|
+
const values = (rawLines) => {
|
|
411
|
+
const parsed = [];
|
|
412
|
+
for (const rawLine of rawLines) {
|
|
413
|
+
const line = ndjsonLine(rawLine);
|
|
414
|
+
if (line === "")
|
|
415
|
+
continue;
|
|
416
|
+
try {
|
|
417
|
+
parsed.push(JSON.parse(line));
|
|
418
|
+
} catch (error) {
|
|
419
|
+
parseFailure(line, error, options?.onParseError);
|
|
420
|
+
}
|
|
421
|
+
}
|
|
422
|
+
return parsed;
|
|
423
|
+
};
|
|
424
|
+
const guarded = (step) => {
|
|
425
|
+
if (failed)
|
|
426
|
+
throw new Error("NDJSON decoder stopped at an earlier error; read the source again");
|
|
427
|
+
try {
|
|
428
|
+
return values(step());
|
|
429
|
+
} catch (error) {
|
|
430
|
+
failed = true;
|
|
431
|
+
throw error;
|
|
432
|
+
}
|
|
433
|
+
};
|
|
434
|
+
return {
|
|
435
|
+
push: (chunk) => guarded(() => lines.push(chunk)),
|
|
436
|
+
end: () => guarded(() => lines.end())
|
|
437
|
+
};
|
|
438
|
+
}
|
|
439
|
+
async function* parseSSE2(source, options) {
|
|
440
|
+
let reporting = false;
|
|
441
|
+
try {
|
|
442
|
+
for await (const rawLine of readBoundedUtf8Lines(source, options?.maxLineBytes ?? DEFAULT_STREAM_LINE_BYTES, false, options?.signal)) {
|
|
443
|
+
const line = rawLine.endsWith("\r") ? rawLine.slice(0, -1) : rawLine;
|
|
444
|
+
if (!line.startsWith("data:"))
|
|
445
|
+
continue;
|
|
446
|
+
const data = line.slice(5).replace(/^ /, "");
|
|
447
|
+
if (data === "[DONE]")
|
|
448
|
+
return;
|
|
449
|
+
let value;
|
|
450
|
+
try {
|
|
451
|
+
value = JSON.parse(data);
|
|
452
|
+
} catch (error) {
|
|
453
|
+
reporting = true;
|
|
454
|
+
parseFailure(data, error, options?.onParseError);
|
|
455
|
+
reporting = false;
|
|
456
|
+
continue;
|
|
457
|
+
}
|
|
458
|
+
yield value;
|
|
459
|
+
}
|
|
460
|
+
} catch (error) {
|
|
461
|
+
if (reporting || options?.signal?.aborted)
|
|
462
|
+
throw error;
|
|
463
|
+
parseFailure("", error, options?.onParseError);
|
|
464
|
+
}
|
|
465
|
+
}
|
|
466
|
+
|
|
467
467
|
// src/browser/contract-stream.ts
|
|
468
468
|
function sourceFor(response, descriptor) {
|
|
469
469
|
const options = {
|