@framers/agentos 0.9.34 → 0.9.36
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/api/agent.d.ts +2 -0
- package/dist/api/agent.d.ts.map +1 -1
- package/dist/api/agent.js +12 -2
- package/dist/api/agent.js.map +1 -1
- package/dist/api/segment.d.ts +14 -0
- package/dist/api/segment.d.ts.map +1 -0
- package/dist/api/segment.js +42 -0
- package/dist/api/segment.js.map +1 -0
- package/dist/api/souledAgent.d.ts +18 -0
- package/dist/api/souledAgent.d.ts.map +1 -0
- package/dist/api/souledAgent.js +98 -0
- package/dist/api/souledAgent.js.map +1 -0
- package/dist/cognition/memory/io/attachMemoryWiki.d.ts +70 -0
- package/dist/cognition/memory/io/attachMemoryWiki.d.ts.map +1 -0
- package/dist/cognition/memory/io/attachMemoryWiki.js +65 -0
- package/dist/cognition/memory/io/attachMemoryWiki.js.map +1 -0
- package/dist/cognition/memory/io/facade/Memory.d.ts +34 -0
- package/dist/cognition/memory/io/facade/Memory.d.ts.map +1 -1
- package/dist/cognition/memory/io/facade/Memory.js +82 -1
- package/dist/cognition/memory/io/facade/Memory.js.map +1 -1
- package/dist/cognition/memory/io/tools/ReadMemoryPageTool.d.ts +39 -0
- package/dist/cognition/memory/io/tools/ReadMemoryPageTool.d.ts.map +1 -0
- package/dist/cognition/memory/io/tools/ReadMemoryPageTool.js +39 -0
- package/dist/cognition/memory/io/tools/ReadMemoryPageTool.js.map +1 -0
- package/dist/cognition/substrate/memory/wiki/WikiCompiler.d.ts +35 -0
- package/dist/cognition/substrate/memory/wiki/WikiCompiler.d.ts.map +1 -0
- package/dist/cognition/substrate/memory/wiki/WikiCompiler.js +51 -0
- package/dist/cognition/substrate/memory/wiki/WikiCompiler.js.map +1 -0
- package/dist/cognition/substrate/memory/wiki/WikiMemoryStore.d.ts +47 -0
- package/dist/cognition/substrate/memory/wiki/WikiMemoryStore.d.ts.map +1 -0
- package/dist/cognition/substrate/memory/wiki/WikiMemoryStore.js +169 -0
- package/dist/cognition/substrate/memory/wiki/WikiMemoryStore.js.map +1 -0
- package/dist/cognition/substrate/memory/wiki/index.d.ts +7 -0
- package/dist/cognition/substrate/memory/wiki/index.d.ts.map +1 -0
- package/dist/cognition/substrate/memory/wiki/index.js +7 -0
- package/dist/cognition/substrate/memory/wiki/index.js.map +1 -0
- package/dist/cognition/substrate/personas/SoulLoader.d.ts +6 -2
- package/dist/cognition/substrate/personas/SoulLoader.d.ts.map +1 -1
- package/dist/cognition/substrate/personas/SoulLoader.js +11 -0
- package/dist/cognition/substrate/personas/SoulLoader.js.map +1 -1
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +7 -0
- package/dist/index.js.map +1 -1
- package/dist/io/segmentation/SegmentationProviderRegistry.d.ts +12 -0
- package/dist/io/segmentation/SegmentationProviderRegistry.d.ts.map +1 -0
- package/dist/io/segmentation/SegmentationProviderRegistry.js +39 -0
- package/dist/io/segmentation/SegmentationProviderRegistry.js.map +1 -0
- package/dist/io/segmentation/consumers/cropRegion.d.ts +16 -0
- package/dist/io/segmentation/consumers/cropRegion.d.ts.map +1 -0
- package/dist/io/segmentation/consumers/cropRegion.js +41 -0
- package/dist/io/segmentation/consumers/cropRegion.js.map +1 -0
- package/dist/io/segmentation/consumers/maskToEditMask.d.ts +19 -0
- package/dist/io/segmentation/consumers/maskToEditMask.d.ts.map +1 -0
- package/dist/io/segmentation/consumers/maskToEditMask.js +32 -0
- package/dist/io/segmentation/consumers/maskToEditMask.js.map +1 -0
- package/dist/io/segmentation/errors.d.ts +32 -0
- package/dist/io/segmentation/errors.d.ts.map +1 -0
- package/dist/io/segmentation/errors.js +29 -0
- package/dist/io/segmentation/errors.js.map +1 -0
- package/dist/io/segmentation/index.d.ts +13 -0
- package/dist/io/segmentation/index.d.ts.map +1 -0
- package/dist/io/segmentation/index.js +13 -0
- package/dist/io/segmentation/index.js.map +1 -0
- package/dist/io/segmentation/maskGeometry.d.ts +13 -0
- package/dist/io/segmentation/maskGeometry.d.ts.map +1 -0
- package/dist/io/segmentation/maskGeometry.js +37 -0
- package/dist/io/segmentation/maskGeometry.js.map +1 -0
- package/dist/io/segmentation/providers/ReplicateSegmentationProvider.d.ts +29 -0
- package/dist/io/segmentation/providers/ReplicateSegmentationProvider.d.ts.map +1 -0
- package/dist/io/segmentation/providers/ReplicateSegmentationProvider.js +235 -0
- package/dist/io/segmentation/providers/ReplicateSegmentationProvider.js.map +1 -0
- package/dist/io/segmentation/resolveMode.d.ts +14 -0
- package/dist/io/segmentation/resolveMode.d.ts.map +1 -0
- package/dist/io/segmentation/resolveMode.js +28 -0
- package/dist/io/segmentation/resolveMode.js.map +1 -0
- package/dist/io/segmentation/types.d.ts +134 -0
- package/dist/io/segmentation/types.d.ts.map +1 -0
- package/dist/io/segmentation/types.js +14 -0
- package/dist/io/segmentation/types.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Combine one or more segmentation masks into a single mask Buffer suitable for
|
|
3
|
+
* `editImage()`'s `mask` input (white = edit region, black = keep).
|
|
4
|
+
*
|
|
5
|
+
* @param masks one mask or many (unioned)
|
|
6
|
+
* @param opts.target `'object'` (default) edits the masked object; `'background'`
|
|
7
|
+
* inverts so everything except the object is edited.
|
|
8
|
+
* @param opts.width/height optional canvas size; defaults to the first mask's.
|
|
9
|
+
*/
|
|
10
|
+
export async function maskToEditMask(masks, opts = {}) {
|
|
11
|
+
const sharp = (await import('sharp')).default;
|
|
12
|
+
const list = Array.isArray(masks) ? masks : [masks];
|
|
13
|
+
if (list.length === 0)
|
|
14
|
+
throw new Error('maskToEditMask requires at least one mask.');
|
|
15
|
+
const first = await sharp(list[0].mask).metadata();
|
|
16
|
+
const width = opts.width ?? first.width ?? 0;
|
|
17
|
+
const height = opts.height ?? first.height ?? 0;
|
|
18
|
+
if (width <= 0 || height <= 0) {
|
|
19
|
+
throw new Error('maskToEditMask: could not determine mask dimensions; pass opts.width and opts.height.');
|
|
20
|
+
}
|
|
21
|
+
const layers = await Promise.all(list.map(async (m) => ({
|
|
22
|
+
input: await sharp(m.mask).resize(width, height, { fit: 'fill' }).greyscale().png().toBuffer(),
|
|
23
|
+
blend: 'screen', // white-on-black union
|
|
24
|
+
})));
|
|
25
|
+
let composed = sharp({ create: { width, height, channels: 3, background: { r: 0, g: 0, b: 0 } } })
|
|
26
|
+
.composite(layers)
|
|
27
|
+
.greyscale();
|
|
28
|
+
if (opts.target === 'background')
|
|
29
|
+
composed = composed.negate();
|
|
30
|
+
return composed.png().toBuffer();
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=maskToEditMask.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maskToEditMask.js","sourceRoot":"","sources":["../../../../src/io/segmentation/consumers/maskToEditMask.ts"],"names":[],"mappings":"AAKA;;;;;;;;GAQG;AACH,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,KAAkC,EAClC,OAA8E,EAAE;IAEhF,MAAM,KAAK,GAAG,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IAC9C,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;IACpD,IAAI,IAAI,CAAC,MAAM,KAAK,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;IAErF,MAAM,KAAK,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;IACnD,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,IAAI,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,IAAI,KAAK,CAAC,MAAM,IAAI,CAAC,CAAC;IAChD,IAAI,KAAK,IAAI,CAAC,IAAI,MAAM,IAAI,CAAC,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,uFAAuF,CAAC,CAAC;IAC3G,CAAC;IAED,MAAM,MAAM,GAAG,MAAM,OAAO,CAAC,GAAG,CAC9B,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;QACrB,KAAK,EAAE,MAAM,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,CAAC,SAAS,EAAE,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE;QAC9F,KAAK,EAAE,QAAiB,EAAE,uBAAuB;KAClD,CAAC,CAAC,CACJ,CAAC;IAEF,IAAI,QAAQ,GAAG,KAAK,CAAC,EAAE,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,UAAU,EAAE,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC;SAC/F,SAAS,CAAC,MAAM,CAAC;SACjB,SAAS,EAAE,CAAC;IAEf,IAAI,IAAI,CAAC,MAAM,KAAK,YAAY;QAAE,QAAQ,GAAG,QAAQ,CAAC,MAAM,EAAE,CAAC;IAC/D,OAAO,QAAQ,CAAC,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;AACnC,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module io/segmentation/errors
|
|
3
|
+
* Typed error classes for the segmentation surface. Callers can catch by class
|
|
4
|
+
* to branch on the failure cause.
|
|
5
|
+
*/
|
|
6
|
+
import type { SegmentationMode } from './types.js';
|
|
7
|
+
/**
|
|
8
|
+
* Thrown before any network call when the resolved provider does not support
|
|
9
|
+
* the requested prompt mode.
|
|
10
|
+
*/
|
|
11
|
+
export declare class SegmentationModeNotSupportedError extends Error {
|
|
12
|
+
/** The provider that was asked to segment. */
|
|
13
|
+
readonly providerId: string;
|
|
14
|
+
/** The unsupported mode. */
|
|
15
|
+
readonly mode: SegmentationMode;
|
|
16
|
+
constructor(providerId: string, mode: SegmentationMode);
|
|
17
|
+
}
|
|
18
|
+
/** Thrown when zero or more than one prompt mode is supplied. */
|
|
19
|
+
export declare class InvalidSegmentationPromptError extends Error {
|
|
20
|
+
constructor(message: string);
|
|
21
|
+
}
|
|
22
|
+
/** Discriminates the kind of provider-level failure. */
|
|
23
|
+
export type SegmentationErrorCode = 'provider_failed' | 'timeout' | 'invalid_request';
|
|
24
|
+
/** Wraps provider/network failures and poll timeouts. */
|
|
25
|
+
export declare class SegmentationProviderError extends Error {
|
|
26
|
+
/** Failure category. */
|
|
27
|
+
readonly code: SegmentationErrorCode;
|
|
28
|
+
/** Underlying cause, when one exists. */
|
|
29
|
+
readonly cause?: unknown;
|
|
30
|
+
constructor(message: string, code: SegmentationErrorCode, cause?: unknown);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/io/segmentation/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAEnD;;;GAGG;AACH,qBAAa,iCAAkC,SAAQ,KAAK;IAC1D,8CAA8C;IAC9C,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,4BAA4B;IAC5B,SAAgB,IAAI,EAAE,gBAAgB,CAAC;gBAE3B,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB;CAMvD;AAED,iEAAiE;AACjE,qBAAa,8BAA+B,SAAQ,KAAK;gBAC3C,OAAO,EAAE,MAAM;CAI5B;AAED,wDAAwD;AACxD,MAAM,MAAM,qBAAqB,GAAG,iBAAiB,GAAG,SAAS,GAAG,iBAAiB,CAAC;AAEtF,yDAAyD;AACzD,qBAAa,yBAA0B,SAAQ,KAAK;IAClD,wBAAwB;IACxB,SAAgB,IAAI,EAAE,qBAAqB,CAAC;IAC5C,yCAAyC;IACzC,SAAgB,KAAK,CAAC,EAAE,OAAO,CAAC;gBAEpB,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,qBAAqB,EAAE,KAAK,CAAC,EAAE,OAAO;CAM1E"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Thrown before any network call when the resolved provider does not support
|
|
3
|
+
* the requested prompt mode.
|
|
4
|
+
*/
|
|
5
|
+
export class SegmentationModeNotSupportedError extends Error {
|
|
6
|
+
constructor(providerId, mode) {
|
|
7
|
+
super(`Segmentation mode "${mode}" is not supported by provider "${providerId}".`);
|
|
8
|
+
this.name = 'SegmentationModeNotSupportedError';
|
|
9
|
+
this.providerId = providerId;
|
|
10
|
+
this.mode = mode;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** Thrown when zero or more than one prompt mode is supplied. */
|
|
14
|
+
export class InvalidSegmentationPromptError extends Error {
|
|
15
|
+
constructor(message) {
|
|
16
|
+
super(message);
|
|
17
|
+
this.name = 'InvalidSegmentationPromptError';
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
/** Wraps provider/network failures and poll timeouts. */
|
|
21
|
+
export class SegmentationProviderError extends Error {
|
|
22
|
+
constructor(message, code, cause) {
|
|
23
|
+
super(message);
|
|
24
|
+
this.name = 'SegmentationProviderError';
|
|
25
|
+
this.code = code;
|
|
26
|
+
this.cause = cause;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/io/segmentation/errors.ts"],"names":[],"mappings":"AAOA;;;GAGG;AACH,MAAM,OAAO,iCAAkC,SAAQ,KAAK;IAM1D,YAAY,UAAkB,EAAE,IAAsB;QACpD,KAAK,CAAC,sBAAsB,IAAI,mCAAmC,UAAU,IAAI,CAAC,CAAC;QACnF,IAAI,CAAC,IAAI,GAAG,mCAAmC,CAAC;QAChD,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED,iEAAiE;AACjE,MAAM,OAAO,8BAA+B,SAAQ,KAAK;IACvD,YAAY,OAAe;QACzB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gCAAgC,CAAC;IAC/C,CAAC;CACF;AAKD,yDAAyD;AACzD,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAMlD,YAAY,OAAe,EAAE,IAA2B,EAAE,KAAe;QACvE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;QACxC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module io/segmentation
|
|
3
|
+
* Public barrel for the image segmentation surface.
|
|
4
|
+
*/
|
|
5
|
+
export * from './types.js';
|
|
6
|
+
export * from './errors.js';
|
|
7
|
+
export { resolveSegmentationMode } from './resolveMode.js';
|
|
8
|
+
export { computeMaskBbox } from './maskGeometry.js';
|
|
9
|
+
export { ReplicateSegmentationProvider } from './providers/ReplicateSegmentationProvider.js';
|
|
10
|
+
export { resolveSegmentationProvider, registerSegmentationProvider, resetSegmentationProviders, } from './SegmentationProviderRegistry.js';
|
|
11
|
+
export { maskToEditMask } from './consumers/maskToEditMask.js';
|
|
12
|
+
export { cropRegion } from './consumers/cropRegion.js';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/io/segmentation/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,6BAA6B,EAAE,MAAM,8CAA8C,CAAC;AAC7F,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module io/segmentation
|
|
3
|
+
* Public barrel for the image segmentation surface.
|
|
4
|
+
*/
|
|
5
|
+
export * from './types.js';
|
|
6
|
+
export * from './errors.js';
|
|
7
|
+
export { resolveSegmentationMode } from './resolveMode.js';
|
|
8
|
+
export { computeMaskBbox } from './maskGeometry.js';
|
|
9
|
+
export { ReplicateSegmentationProvider } from './providers/ReplicateSegmentationProvider.js';
|
|
10
|
+
export { resolveSegmentationProvider, registerSegmentationProvider, resetSegmentationProviders, } from './SegmentationProviderRegistry.js';
|
|
11
|
+
export { maskToEditMask } from './consumers/maskToEditMask.js';
|
|
12
|
+
export { cropRegion } from './consumers/cropRegion.js';
|
|
13
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/io/segmentation/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,cAAc,YAAY,CAAC;AAC3B,cAAc,aAAa,CAAC;AAC5B,OAAO,EAAE,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EAAE,6BAA6B,EAAE,MAAM,8CAA8C,CAAC;AAC7F,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC5B,0BAA0B,GAC3B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAC/D,OAAO,EAAE,UAAU,EAAE,MAAM,2BAA2B,CAAC"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module io/segmentation/maskGeometry
|
|
3
|
+
*/
|
|
4
|
+
import type { SegmentationBox } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Compute the tight bounding box of the white (luma >= 128) pixels in a mask.
|
|
7
|
+
* Returns `null` when the mask has no white pixels.
|
|
8
|
+
*
|
|
9
|
+
* sharp is loaded lazily, matching the guarded dynamic-import pattern used by
|
|
10
|
+
* the vision pipeline (src/io/vision/VisionPipeline.ts).
|
|
11
|
+
*/
|
|
12
|
+
export declare function computeMaskBbox(maskPng: Buffer): Promise<SegmentationBox | null>;
|
|
13
|
+
//# sourceMappingURL=maskGeometry.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maskGeometry.d.ts","sourceRoot":"","sources":["../../../src/io/segmentation/maskGeometry.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAElD;;;;;;GAMG;AACH,wBAAsB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAwBtF"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Compute the tight bounding box of the white (luma >= 128) pixels in a mask.
|
|
3
|
+
* Returns `null` when the mask has no white pixels.
|
|
4
|
+
*
|
|
5
|
+
* sharp is loaded lazily, matching the guarded dynamic-import pattern used by
|
|
6
|
+
* the vision pipeline (src/io/vision/VisionPipeline.ts).
|
|
7
|
+
*/
|
|
8
|
+
export async function computeMaskBbox(maskPng) {
|
|
9
|
+
const sharp = (await import('sharp')).default;
|
|
10
|
+
const { data, info } = await sharp(maskPng)
|
|
11
|
+
.greyscale()
|
|
12
|
+
.raw()
|
|
13
|
+
.toBuffer({ resolveWithObject: true });
|
|
14
|
+
const { width, height, channels } = info;
|
|
15
|
+
let minX = width;
|
|
16
|
+
let minY = height;
|
|
17
|
+
let maxX = -1;
|
|
18
|
+
let maxY = -1;
|
|
19
|
+
for (let y = 0; y < height; y++) {
|
|
20
|
+
for (let x = 0; x < width; x++) {
|
|
21
|
+
if (data[(y * width + x) * channels] >= 128) {
|
|
22
|
+
if (x < minX)
|
|
23
|
+
minX = x;
|
|
24
|
+
if (y < minY)
|
|
25
|
+
minY = y;
|
|
26
|
+
if (x > maxX)
|
|
27
|
+
maxX = x;
|
|
28
|
+
if (y > maxY)
|
|
29
|
+
maxY = y;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
if (maxX < 0)
|
|
34
|
+
return null;
|
|
35
|
+
return { x: minX, y: minY, width: maxX - minX + 1, height: maxY - minY + 1 };
|
|
36
|
+
}
|
|
37
|
+
//# sourceMappingURL=maskGeometry.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"maskGeometry.js","sourceRoot":"","sources":["../../../src/io/segmentation/maskGeometry.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,OAAe;IACnD,MAAM,KAAK,GAAG,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;IAC9C,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,GAAG,MAAM,KAAK,CAAC,OAAO,CAAC;SACxC,SAAS,EAAE;SACX,GAAG,EAAE;SACL,QAAQ,CAAC,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;IAEzC,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,CAAC;IACzC,IAAI,IAAI,GAAG,KAAK,CAAC;IACjB,IAAI,IAAI,GAAG,MAAM,CAAC;IAClB,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC;IACd,IAAI,IAAI,GAAG,CAAC,CAAC,CAAC;IACd,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC;YAC/B,IAAI,IAAI,CAAC,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,IAAI,GAAG,EAAE,CAAC;gBAC5C,IAAI,CAAC,GAAG,IAAI;oBAAE,IAAI,GAAG,CAAC,CAAC;gBACvB,IAAI,CAAC,GAAG,IAAI;oBAAE,IAAI,GAAG,CAAC,CAAC;gBACvB,IAAI,CAAC,GAAG,IAAI;oBAAE,IAAI,GAAG,CAAC,CAAC;gBACvB,IAAI,CAAC,GAAG,IAAI;oBAAE,IAAI,GAAG,CAAC,CAAC;YACzB,CAAC;QACH,CAAC;IACH,CAAC;IACD,IAAI,IAAI,GAAG,CAAC;QAAE,OAAO,IAAI,CAAC;IAC1B,OAAO,EAAE,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,IAAI,EAAE,KAAK,EAAE,IAAI,GAAG,IAAI,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC;AAC/E,CAAC"}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { ISegmentationProvider, SegmentationMode, SegmentationRequest, SegmentationResult } from '../types.js';
|
|
2
|
+
export declare class ReplicateSegmentationProvider implements ISegmentationProvider {
|
|
3
|
+
readonly providerId = "replicate";
|
|
4
|
+
isInitialized: boolean;
|
|
5
|
+
defaultModelId?: string;
|
|
6
|
+
private keyPool;
|
|
7
|
+
private readonly versionCache;
|
|
8
|
+
initialize(config: Record<string, unknown>): Promise<void>;
|
|
9
|
+
supportedModes(): ReadonlyArray<SegmentationMode>;
|
|
10
|
+
segment(request: SegmentationRequest): Promise<SegmentationResult>;
|
|
11
|
+
/**
|
|
12
|
+
* Build the Replicate `input` object for the request's mode. Field names
|
|
13
|
+
* target the v1 output contract; confirm per chosen model in the smoke step.
|
|
14
|
+
*/
|
|
15
|
+
private buildInput;
|
|
16
|
+
private headers;
|
|
17
|
+
private runPrediction;
|
|
18
|
+
/**
|
|
19
|
+
* Resolve a model id to a concrete version hash. An explicit
|
|
20
|
+
* `owner/name:version` pin is used directly; a bare `owner/name` is looked up
|
|
21
|
+
* via the model API for its latest version (cached per provider instance).
|
|
22
|
+
*/
|
|
23
|
+
private resolveVersion;
|
|
24
|
+
private extractMaskRefs;
|
|
25
|
+
private fetchMaskBytes;
|
|
26
|
+
private decodeMasks;
|
|
27
|
+
private imageDimensions;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=ReplicateSegmentationProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReplicateSegmentationProvider.d.ts","sourceRoot":"","sources":["../../../../src/io/segmentation/providers/ReplicateSegmentationProvider.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACV,qBAAqB,EAErB,gBAAgB,EAChB,mBAAmB,EACnB,kBAAkB,EAEnB,MAAM,aAAa,CAAC;AAsBrB,qBAAa,6BAA8B,YAAW,qBAAqB;IACzE,SAAgB,UAAU,eAAe;IAClC,aAAa,UAAS;IACtB,cAAc,CAAC,EAAE,MAAM,CAAC;IAC/B,OAAO,CAAC,OAAO,CAAc;IAC7B,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA6B;IAEpD,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAahE,cAAc,IAAI,aAAa,CAAC,gBAAgB,CAAC;IAO3C,OAAO,CAAC,OAAO,EAAE,mBAAmB,GAAG,OAAO,CAAC,kBAAkB,CAAC;IA6DxE;;;OAGG;IACH,OAAO,CAAC,UAAU;IAelB,OAAO,CAAC,OAAO;YAID,aAAa;IAqC3B;;;;OAIG;YACW,cAAc;IA6B5B,OAAO,CAAC,eAAe;YAcT,cAAc;YAWd,WAAW;YAwBX,eAAe;CAK9B"}
|
|
@@ -0,0 +1,235 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module io/segmentation/providers/ReplicateSegmentationProvider
|
|
3
|
+
*
|
|
4
|
+
* Hosted segmentation via Replicate. Geometric prompts (points/box/automatic)
|
|
5
|
+
* route to a SAM2 model; text prompts route to a GroundedSAM model. Contains
|
|
6
|
+
* its own minimal predict/poll cycle (no dependency on the image provider).
|
|
7
|
+
*/
|
|
8
|
+
import { ApiKeyPool } from '../../../core/providers/ApiKeyPool.js';
|
|
9
|
+
import { getImageProviderOptions } from '../../media/images/IImageProvider.js';
|
|
10
|
+
import { SegmentationProviderError, SegmentationModeNotSupportedError } from '../errors.js';
|
|
11
|
+
import { computeMaskBbox } from '../maskGeometry.js';
|
|
12
|
+
const REPLICATE_BASE = 'https://api.replicate.com/v1';
|
|
13
|
+
/** Default SAM2 model for geometric prompts. Verify/adjust in the smoke step. */
|
|
14
|
+
const DEFAULT_SAM_MODEL = 'meta/sam-2';
|
|
15
|
+
/** Default GroundedSAM model for text prompts. Verify/adjust in the smoke step. */
|
|
16
|
+
const DEFAULT_GROUNDED_SAM_MODEL = 'schananas/grounded_sam';
|
|
17
|
+
function sleep(ms) {
|
|
18
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
19
|
+
}
|
|
20
|
+
export class ReplicateSegmentationProvider {
|
|
21
|
+
constructor() {
|
|
22
|
+
this.providerId = 'replicate';
|
|
23
|
+
this.isInitialized = false;
|
|
24
|
+
this.versionCache = new Map();
|
|
25
|
+
}
|
|
26
|
+
async initialize(config) {
|
|
27
|
+
const apiKey = typeof config.apiKey === 'string' ? config.apiKey.trim() : '';
|
|
28
|
+
if (!apiKey) {
|
|
29
|
+
throw new SegmentationProviderError('Replicate segmentation provider requires apiKey.', 'provider_failed');
|
|
30
|
+
}
|
|
31
|
+
this.keyPool = new ApiKeyPool(apiKey);
|
|
32
|
+
this.defaultModelId =
|
|
33
|
+
typeof config.defaultModelId === 'string' && config.defaultModelId.trim()
|
|
34
|
+
? config.defaultModelId.trim()
|
|
35
|
+
: DEFAULT_SAM_MODEL;
|
|
36
|
+
this.isInitialized = true;
|
|
37
|
+
}
|
|
38
|
+
supportedModes() {
|
|
39
|
+
// Hosted Replicate v1: GroundedSAM (text) + SAM2 automatic ("segment
|
|
40
|
+
// everything"). Coordinate prompts (points/box) have no clean hosted
|
|
41
|
+
// single-image model and await a coordinate-capable provider.
|
|
42
|
+
return ['text', 'automatic'];
|
|
43
|
+
}
|
|
44
|
+
async segment(request) {
|
|
45
|
+
if (!this.isInitialized) {
|
|
46
|
+
throw new SegmentationProviderError('Replicate segmentation provider is not initialized.', 'provider_failed');
|
|
47
|
+
}
|
|
48
|
+
if (!this.supportedModes().includes(request.mode)) {
|
|
49
|
+
throw new SegmentationModeNotSupportedError(this.providerId, request.mode);
|
|
50
|
+
}
|
|
51
|
+
const startedAt = Date.now();
|
|
52
|
+
const providerOptions = getImageProviderOptions(this.providerId, request.providerOptions);
|
|
53
|
+
const isText = request.mode === 'text';
|
|
54
|
+
const modelId = request.modelId
|
|
55
|
+
|| (isText
|
|
56
|
+
? (providerOptions?.groundedSamModelId ?? DEFAULT_GROUNDED_SAM_MODEL)
|
|
57
|
+
: (providerOptions?.samModelId ?? this.defaultModelId ?? DEFAULT_SAM_MODEL));
|
|
58
|
+
const input = this.buildInput(request, providerOptions);
|
|
59
|
+
let prediction;
|
|
60
|
+
try {
|
|
61
|
+
prediction = await this.runPrediction(modelId, input, providerOptions);
|
|
62
|
+
}
|
|
63
|
+
catch (err) {
|
|
64
|
+
if (err instanceof SegmentationProviderError)
|
|
65
|
+
throw err;
|
|
66
|
+
throw new SegmentationProviderError(`Replicate segmentation request failed: ${err.message}`, 'provider_failed', err);
|
|
67
|
+
}
|
|
68
|
+
if (prediction.status === 'failed') {
|
|
69
|
+
throw new SegmentationProviderError(`Replicate segmentation failed: ${prediction.error ?? 'unknown error'}`, 'provider_failed');
|
|
70
|
+
}
|
|
71
|
+
if (prediction.status === 'canceled') {
|
|
72
|
+
throw new SegmentationProviderError('Replicate segmentation was canceled.', 'provider_failed');
|
|
73
|
+
}
|
|
74
|
+
const { width, height } = await this.imageDimensions(request.image);
|
|
75
|
+
let masks = await this.decodeMasks(prediction.output);
|
|
76
|
+
if (typeof request.minScore === 'number')
|
|
77
|
+
masks = masks.filter((m) => m.score >= request.minScore);
|
|
78
|
+
if (typeof request.maxMasks === 'number')
|
|
79
|
+
masks = masks.slice(0, request.maxMasks);
|
|
80
|
+
masks = masks.map((m, i) => ({
|
|
81
|
+
...m,
|
|
82
|
+
index: i,
|
|
83
|
+
// GroundedSAM output carries no per-mask label; fall back to the phrase.
|
|
84
|
+
label: m.label ?? (request.mode === 'text' ? request.prompt : undefined),
|
|
85
|
+
}));
|
|
86
|
+
return {
|
|
87
|
+
masks,
|
|
88
|
+
width,
|
|
89
|
+
height,
|
|
90
|
+
providerId: this.providerId,
|
|
91
|
+
modelId,
|
|
92
|
+
promptMode: request.mode,
|
|
93
|
+
usage: { totalMasks: masks.length },
|
|
94
|
+
durationMs: Date.now() - startedAt,
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Build the Replicate `input` object for the request's mode. Field names
|
|
99
|
+
* target the v1 output contract; confirm per chosen model in the smoke step.
|
|
100
|
+
*/
|
|
101
|
+
buildInput(request, providerOptions) {
|
|
102
|
+
const imageDataUrl = `data:image/png;base64,${request.image.toString('base64')}`;
|
|
103
|
+
const input = { image: imageDataUrl, ...(providerOptions?.input ?? {}) };
|
|
104
|
+
if (request.mode === 'text') {
|
|
105
|
+
// GroundedSAM uses `mask_prompt` for the open-vocabulary phrase.
|
|
106
|
+
input.mask_prompt = request.prompt;
|
|
107
|
+
}
|
|
108
|
+
// `automatic` mode: the SAM2 model segments everything from `image` alone.
|
|
109
|
+
// Tuning params (points_per_side, pred_iou_thresh, stability_score_thresh,
|
|
110
|
+
// use_m2m) flow through providerOptions.replicate.input.
|
|
111
|
+
return input;
|
|
112
|
+
}
|
|
113
|
+
headers() {
|
|
114
|
+
return { Authorization: `Token ${this.keyPool.next()}`, 'Content-Type': 'application/json' };
|
|
115
|
+
}
|
|
116
|
+
async runPrediction(modelId, input, providerOptions) {
|
|
117
|
+
const pollIntervalMs = providerOptions?.pollIntervalMs ?? 1000;
|
|
118
|
+
const timeoutMs = providerOptions?.timeoutMs ?? 120000;
|
|
119
|
+
// Create the prediction through the version endpoint, which serves both
|
|
120
|
+
// official and community models. The version-less /models/.../predictions
|
|
121
|
+
// endpoint only serves official models and 404s for community ones.
|
|
122
|
+
const version = await this.resolveVersion(modelId);
|
|
123
|
+
const res = await fetch(`${REPLICATE_BASE}/predictions`, {
|
|
124
|
+
method: 'POST', headers: this.headers(), body: JSON.stringify({ version, input }),
|
|
125
|
+
});
|
|
126
|
+
if (!res.ok) {
|
|
127
|
+
throw new SegmentationProviderError(`Replicate returned ${res.status}: ${await res.text()}`, 'provider_failed');
|
|
128
|
+
}
|
|
129
|
+
let prediction = (await res.json());
|
|
130
|
+
const deadline = Date.now() + timeoutMs;
|
|
131
|
+
while (prediction.status
|
|
132
|
+
&& !['succeeded', 'failed', 'canceled'].includes(prediction.status)
|
|
133
|
+
&& prediction.urls?.get) {
|
|
134
|
+
if (Date.now() > deadline) {
|
|
135
|
+
throw new SegmentationProviderError('Replicate segmentation timed out.', 'timeout');
|
|
136
|
+
}
|
|
137
|
+
await sleep(pollIntervalMs);
|
|
138
|
+
const pollRes = await fetch(prediction.urls.get, { headers: this.headers() });
|
|
139
|
+
if (!pollRes.ok) {
|
|
140
|
+
throw new SegmentationProviderError(`Replicate poll returned ${pollRes.status}.`, 'provider_failed');
|
|
141
|
+
}
|
|
142
|
+
prediction = (await pollRes.json());
|
|
143
|
+
}
|
|
144
|
+
return prediction;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Resolve a model id to a concrete version hash. An explicit
|
|
148
|
+
* `owner/name:version` pin is used directly; a bare `owner/name` is looked up
|
|
149
|
+
* via the model API for its latest version (cached per provider instance).
|
|
150
|
+
*/
|
|
151
|
+
async resolveVersion(modelId) {
|
|
152
|
+
const colon = modelId.indexOf(':');
|
|
153
|
+
if (colon >= 0)
|
|
154
|
+
return modelId.slice(colon + 1);
|
|
155
|
+
const cached = this.versionCache.get(modelId);
|
|
156
|
+
if (cached)
|
|
157
|
+
return cached;
|
|
158
|
+
// Require exactly "owner/name" (both non-empty) before building the model
|
|
159
|
+
// URL, so a malformed override can't produce a "models//name" path.
|
|
160
|
+
const parts = modelId.split('/');
|
|
161
|
+
if (parts.length !== 2 || !parts[0] || !parts[1]) {
|
|
162
|
+
throw new SegmentationProviderError(`Invalid modelId "${modelId}": expected "owner/model" or "owner/model:version".`, 'invalid_request');
|
|
163
|
+
}
|
|
164
|
+
const res = await fetch(`${REPLICATE_BASE}/models/${modelId}`, { headers: this.headers() });
|
|
165
|
+
if (!res.ok) {
|
|
166
|
+
throw new SegmentationProviderError(`Failed to resolve model "${modelId}": ${res.status}`, 'provider_failed');
|
|
167
|
+
}
|
|
168
|
+
const data = (await res.json());
|
|
169
|
+
const version = data.latest_version?.id;
|
|
170
|
+
if (!version) {
|
|
171
|
+
throw new SegmentationProviderError(`Model "${modelId}" has no published version.`, 'provider_failed');
|
|
172
|
+
}
|
|
173
|
+
this.versionCache.set(modelId, version);
|
|
174
|
+
return version;
|
|
175
|
+
}
|
|
176
|
+
extractMaskRefs(output) {
|
|
177
|
+
if (Array.isArray(output))
|
|
178
|
+
return output;
|
|
179
|
+
if (output && typeof output === 'object') {
|
|
180
|
+
const o = output;
|
|
181
|
+
// meta/sam-2 automatic output: { combined_mask, individual_masks: [...] }
|
|
182
|
+
if (Array.isArray(o.individual_masks))
|
|
183
|
+
return o.individual_masks;
|
|
184
|
+
if (Array.isArray(o.masks))
|
|
185
|
+
return o.masks;
|
|
186
|
+
if (typeof o.mask === 'string')
|
|
187
|
+
return [o.mask];
|
|
188
|
+
if (typeof o.combined_mask === 'string')
|
|
189
|
+
return [o.combined_mask];
|
|
190
|
+
}
|
|
191
|
+
if (typeof output === 'string')
|
|
192
|
+
return [output];
|
|
193
|
+
return [];
|
|
194
|
+
}
|
|
195
|
+
async fetchMaskBytes(url) {
|
|
196
|
+
if (url.startsWith('data:')) {
|
|
197
|
+
return Buffer.from(url.substring(url.indexOf(',') + 1), 'base64');
|
|
198
|
+
}
|
|
199
|
+
const res = await fetch(url, { headers: this.headers() });
|
|
200
|
+
if (!res.ok) {
|
|
201
|
+
throw new SegmentationProviderError(`Failed to download mask: ${res.status}`, 'provider_failed');
|
|
202
|
+
}
|
|
203
|
+
return Buffer.from(await res.arrayBuffer());
|
|
204
|
+
}
|
|
205
|
+
async decodeMasks(output) {
|
|
206
|
+
const refs = this.extractMaskRefs(output);
|
|
207
|
+
const masks = [];
|
|
208
|
+
for (let i = 0; i < refs.length; i++) {
|
|
209
|
+
const ref = refs[i];
|
|
210
|
+
const url = typeof ref === 'string' ? ref : ref.mask;
|
|
211
|
+
if (typeof url !== 'string')
|
|
212
|
+
continue;
|
|
213
|
+
const png = await this.fetchMaskBytes(url);
|
|
214
|
+
const bbox = typeof ref === 'object' && Array.isArray(ref.box) && ref.box.length === 4
|
|
215
|
+
? { x: ref.box[0], y: ref.box[1], width: ref.box[2] - ref.box[0], height: ref.box[3] - ref.box[1] }
|
|
216
|
+
: await computeMaskBbox(png);
|
|
217
|
+
if (!bbox)
|
|
218
|
+
continue;
|
|
219
|
+
masks.push({
|
|
220
|
+
mask: png,
|
|
221
|
+
bbox,
|
|
222
|
+
score: typeof ref === 'object' && typeof ref.score === 'number' ? ref.score : 1,
|
|
223
|
+
label: typeof ref === 'object' && typeof ref.label === 'string' ? ref.label : undefined,
|
|
224
|
+
index: i,
|
|
225
|
+
});
|
|
226
|
+
}
|
|
227
|
+
return masks;
|
|
228
|
+
}
|
|
229
|
+
async imageDimensions(image) {
|
|
230
|
+
const sharp = (await import('sharp')).default;
|
|
231
|
+
const meta = await sharp(image).metadata();
|
|
232
|
+
return { width: meta.width ?? 0, height: meta.height ?? 0 };
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
//# sourceMappingURL=ReplicateSegmentationProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ReplicateSegmentationProvider.js","sourceRoot":"","sources":["../../../../src/io/segmentation/providers/ReplicateSegmentationProvider.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,UAAU,EAAE,MAAM,uCAAuC,CAAC;AACnE,OAAO,EAAE,uBAAuB,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,yBAAyB,EAAE,iCAAiC,EAAE,MAAM,cAAc,CAAC;AAC5F,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAUrD,MAAM,cAAc,GAAG,8BAA8B,CAAC;AACtD,iFAAiF;AACjF,MAAM,iBAAiB,GAAG,YAAY,CAAC;AACvC,mFAAmF;AACnF,MAAM,0BAA0B,GAAG,wBAAwB,CAAC;AAY5D,SAAS,KAAK,CAAC,EAAU;IACvB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED,MAAM,OAAO,6BAA6B;IAA1C;QACkB,eAAU,GAAG,WAAW,CAAC;QAClC,kBAAa,GAAG,KAAK,CAAC;QAGZ,iBAAY,GAAG,IAAI,GAAG,EA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KAAa;QACzC,MAAM,KAAK,GAAG,CAAC,MAAM,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,OAAO,CAAC;QAC9C,MAAM,IAAI,GAAG,MAAM,KAAK,CAAC,KAAK,CAAC,CAAC,QAAQ,EAAE,CAAC;QAC3C,OAAO,EAAE,KAAK,EAAE,IAAI,CAAC,KAAK,IAAI,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;IAC9D,CAAC;CACF"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module io/segmentation/resolveMode
|
|
3
|
+
*/
|
|
4
|
+
import type { SegmentOptions, SegmentationMode } from './types.js';
|
|
5
|
+
/**
|
|
6
|
+
* Determine the single active prompt mode from the options.
|
|
7
|
+
*
|
|
8
|
+
* A mode counts as "set" when: `prompt` is a non-empty (trimmed) string,
|
|
9
|
+
* `points` is a non-empty array, `box` is present, or `automatic === true`.
|
|
10
|
+
*
|
|
11
|
+
* @throws {InvalidSegmentationPromptError} when zero or more than one is set.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveSegmentationMode(opts: SegmentOptions): SegmentationMode;
|
|
14
|
+
//# sourceMappingURL=resolveMode.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveMode.d.ts","sourceRoot":"","sources":["../../../src/io/segmentation/resolveMode.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAGnE;;;;;;;GAOG;AACH,wBAAgB,uBAAuB,CAAC,IAAI,EAAE,cAAc,GAAG,gBAAgB,CAkB9E"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { InvalidSegmentationPromptError } from './errors.js';
|
|
2
|
+
/**
|
|
3
|
+
* Determine the single active prompt mode from the options.
|
|
4
|
+
*
|
|
5
|
+
* A mode counts as "set" when: `prompt` is a non-empty (trimmed) string,
|
|
6
|
+
* `points` is a non-empty array, `box` is present, or `automatic === true`.
|
|
7
|
+
*
|
|
8
|
+
* @throws {InvalidSegmentationPromptError} when zero or more than one is set.
|
|
9
|
+
*/
|
|
10
|
+
export function resolveSegmentationMode(opts) {
|
|
11
|
+
const modes = [];
|
|
12
|
+
if (typeof opts.prompt === 'string' && opts.prompt.trim().length > 0)
|
|
13
|
+
modes.push('text');
|
|
14
|
+
if (Array.isArray(opts.points) && opts.points.length > 0)
|
|
15
|
+
modes.push('points');
|
|
16
|
+
if (opts.box)
|
|
17
|
+
modes.push('box');
|
|
18
|
+
if (opts.automatic === true)
|
|
19
|
+
modes.push('automatic');
|
|
20
|
+
if (modes.length === 0) {
|
|
21
|
+
throw new InvalidSegmentationPromptError('segment() requires exactly one prompt mode: set one of prompt, points, box, or automatic.');
|
|
22
|
+
}
|
|
23
|
+
if (modes.length > 1) {
|
|
24
|
+
throw new InvalidSegmentationPromptError(`segment() accepts exactly one prompt mode, received: ${modes.join(', ')}.`);
|
|
25
|
+
}
|
|
26
|
+
return modes[0];
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=resolveMode.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"resolveMode.js","sourceRoot":"","sources":["../../../src/io/segmentation/resolveMode.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,8BAA8B,EAAE,MAAM,aAAa,CAAC;AAE7D;;;;;;;GAOG;AACH,MAAM,UAAU,uBAAuB,CAAC,IAAoB;IAC1D,MAAM,KAAK,GAAuB,EAAE,CAAC;IACrC,IAAI,OAAO,IAAI,CAAC,MAAM,KAAK,QAAQ,IAAI,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACzF,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC;QAAE,KAAK,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC/E,IAAI,IAAI,CAAC,GAAG;QAAE,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAChC,IAAI,IAAI,CAAC,SAAS,KAAK,IAAI;QAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;IAErD,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QACvB,MAAM,IAAI,8BAA8B,CACtC,2FAA2F,CAC5F,CAAC;IACJ,CAAC;IACD,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACrB,MAAM,IAAI,8BAA8B,CACtC,wDAAwD,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,CAC5E,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC"}
|