@sapiom/tools 0.6.2 → 0.7.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 +6 -0
- package/README.md +16 -11
- package/dist/cjs/_client/index.d.ts +22 -2
- package/dist/cjs/_client/index.d.ts.map +1 -1
- package/dist/cjs/_client/index.js +16 -6
- package/dist/cjs/_client/index.js.map +1 -1
- package/dist/cjs/client.d.ts +20 -1
- package/dist/cjs/client.d.ts.map +1 -1
- package/dist/cjs/client.js +8 -0
- package/dist/cjs/client.js.map +1 -1
- package/dist/cjs/content-generation/index.d.ts +55 -3
- package/dist/cjs/content-generation/index.d.ts.map +1 -1
- package/dist/cjs/content-generation/index.js +76 -4
- package/dist/cjs/content-generation/index.js.map +1 -1
- package/dist/cjs/index.d.ts +3 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +4 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/search/errors.d.ts +16 -0
- package/dist/cjs/search/errors.d.ts.map +1 -0
- package/dist/cjs/search/errors.js +36 -0
- package/dist/cjs/search/errors.js.map +1 -0
- package/dist/cjs/search/index.d.ts +105 -0
- package/dist/cjs/search/index.d.ts.map +1 -0
- package/dist/cjs/search/index.js +129 -0
- package/dist/cjs/search/index.js.map +1 -0
- package/dist/cjs/stub/index.d.ts.map +1 -1
- package/dist/cjs/stub/index.js +39 -1
- package/dist/cjs/stub/index.js.map +1 -1
- package/dist/esm/_client/index.d.ts +22 -2
- package/dist/esm/_client/index.d.ts.map +1 -1
- package/dist/esm/_client/index.js +16 -6
- package/dist/esm/_client/index.js.map +1 -1
- package/dist/esm/client.d.ts +20 -1
- package/dist/esm/client.d.ts.map +1 -1
- package/dist/esm/client.js +8 -0
- package/dist/esm/client.js.map +1 -1
- package/dist/esm/content-generation/index.d.ts +55 -3
- package/dist/esm/content-generation/index.d.ts.map +1 -1
- package/dist/esm/content-generation/index.js +74 -3
- package/dist/esm/content-generation/index.js.map +1 -1
- package/dist/esm/index.d.ts +3 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +3 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/search/errors.d.ts +16 -0
- package/dist/esm/search/errors.d.ts.map +1 -0
- package/dist/esm/search/errors.js +31 -0
- package/dist/esm/search/errors.js.map +1 -0
- package/dist/esm/search/index.d.ts +105 -0
- package/dist/esm/search/index.d.ts.map +1 -0
- package/dist/esm/search/index.js +124 -0
- package/dist/esm/search/index.js.map +1 -0
- package/dist/esm/stub/index.d.ts.map +1 -1
- package/dist/esm/stub/index.js +39 -1
- package/dist/esm/stub/index.js.map +1 -1
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +6 -1
- package/src/content-generation/README.md +23 -2
- package/src/search/README.md +126 -0
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `contentGeneration` capability — generate media (images
|
|
2
|
+
* `contentGeneration` capability — generate media (images and video today; audio
|
|
3
3
|
* to come), with an optional `storage` param that persists each output to Sapiom
|
|
4
4
|
* file storage so you get a durable `fileId` back inline.
|
|
5
5
|
*
|
|
@@ -78,10 +78,62 @@ export interface ImageGenerationResult {
|
|
|
78
78
|
export declare function createImage(input: ImageCreateInput, transport?: Transport, baseUrl?: string): Promise<ImageGenerationResult>;
|
|
79
79
|
/**
|
|
80
80
|
* The `images` sub-namespace, so `contentGeneration.images.create(...)` reads the
|
|
81
|
-
* same whether imported from the barrel or used on a client.
|
|
82
|
-
* land here as sibling sub-namespaces.
|
|
81
|
+
* same whether imported from the barrel or used on a client.
|
|
83
82
|
*/
|
|
84
83
|
export declare const images: {
|
|
85
84
|
create: typeof createImage;
|
|
86
85
|
};
|
|
86
|
+
export interface VideoCreateInput {
|
|
87
|
+
/** Text prompt describing the video to generate. */
|
|
88
|
+
prompt: string;
|
|
89
|
+
/**
|
|
90
|
+
* Optional model selector. Defaults to a standard video model; most callers omit it.
|
|
91
|
+
* (Model identifiers are an advanced, evolving surface.)
|
|
92
|
+
*/
|
|
93
|
+
model?: string;
|
|
94
|
+
/**
|
|
95
|
+
* Optional: persist the generated output to Sapiom file storage. When set, the
|
|
96
|
+
* returned `video` comes back annotated with `fileId` (or `storageError` if
|
|
97
|
+
* persisting failed).
|
|
98
|
+
*/
|
|
99
|
+
storage?: StorageOptions;
|
|
100
|
+
/** Advanced: extra model-specific parameters, forwarded verbatim. */
|
|
101
|
+
params?: Record<string, unknown>;
|
|
102
|
+
/** How often to poll while the video generates (default 5s). */
|
|
103
|
+
pollIntervalMs?: number;
|
|
104
|
+
/** Give up and throw if the result isn't ready within this window (default 5 min). */
|
|
105
|
+
timeoutMs?: number;
|
|
106
|
+
}
|
|
107
|
+
export interface GeneratedVideo {
|
|
108
|
+
/** Hosted URL of the generated video. */
|
|
109
|
+
url: string;
|
|
110
|
+
/** MIME type, when reported. */
|
|
111
|
+
contentType?: string;
|
|
112
|
+
/**
|
|
113
|
+
* Present when `storage` was requested and the output was persisted — pass to
|
|
114
|
+
* `fileStorage.getDownloadUrl(fileId)` to retrieve it.
|
|
115
|
+
*/
|
|
116
|
+
fileId?: string;
|
|
117
|
+
/** Present when `storage` was requested but persisting the output failed. */
|
|
118
|
+
storageError?: string;
|
|
119
|
+
}
|
|
120
|
+
export interface VideoGenerationResult {
|
|
121
|
+
/** The generated video. */
|
|
122
|
+
video?: GeneratedVideo;
|
|
123
|
+
/** Additional model-specific fields (e.g. `seed`, `timings`), returned as-is. */
|
|
124
|
+
[key: string]: unknown;
|
|
125
|
+
}
|
|
126
|
+
/**
|
|
127
|
+
* Generate a video from a prompt. Video generation is asynchronous: this submits the
|
|
128
|
+
* job, then polls the result through Sapiom until it's ready and returns it — so you
|
|
129
|
+
* `await` it just like {@link createImage}, it just takes longer. Pass `storage` to
|
|
130
|
+
* persist the output (the returned `video` then carries `fileId`). Throws
|
|
131
|
+
* {@link ContentGenerationHttpError} on a failed submit, or an `Error` if the result
|
|
132
|
+
* isn't ready within `timeoutMs`.
|
|
133
|
+
*/
|
|
134
|
+
export declare function createVideo(input: VideoCreateInput, transport?: Transport, baseUrl?: string): Promise<VideoGenerationResult>;
|
|
135
|
+
/** The `video` sub-namespace: `contentGeneration.video.create(...)`. Async (submit + poll). */
|
|
136
|
+
export declare const video: {
|
|
137
|
+
create: typeof createVideo;
|
|
138
|
+
};
|
|
87
139
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/content-generation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,SAAS,EAAoB,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAY,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,EAAE,0BAA0B,EAAE,CAAC;AAUtC,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,UAAU,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;CACnC;AAED,MAAM,WAAW,gBAAgB;IAC/B,oDAAoD;IACpD,MAAM,EAAE,MAAM,CAAC;IACf,oCAAoC;IACpC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAClC;AAED,MAAM,WAAW,cAAc;IAC7B,yCAAyC;IACzC,GAAG,EAAE,MAAM,CAAC;IACZ,gCAAgC;IAChC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;OAGG;IAC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ACzC,OAAO,SAAmB,GACzB,OAAO,CAAC,qBAAqB,CAAC,CA8ChC;AAED,+FAA+F;AAC/F,eAAO,MAAM,KAAK;;CAA0B,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* `contentGeneration` capability — generate media (images
|
|
2
|
+
* `contentGeneration` capability — generate media (images and video today; audio
|
|
3
3
|
* to come), with an optional `storage` param that persists each output to Sapiom
|
|
4
4
|
* file storage so you get a durable `fileId` back inline.
|
|
5
5
|
*
|
|
@@ -66,8 +66,79 @@ export async function createImage(input, transport = defaultTransport(), baseUrl
|
|
|
66
66
|
}
|
|
67
67
|
/**
|
|
68
68
|
* The `images` sub-namespace, so `contentGeneration.images.create(...)` reads the
|
|
69
|
-
* same whether imported from the barrel or used on a client.
|
|
70
|
-
* land here as sibling sub-namespaces.
|
|
69
|
+
* same whether imported from the barrel or used on a client.
|
|
71
70
|
*/
|
|
72
71
|
export const images = { create: createImage };
|
|
72
|
+
// ----- Video (async) -----
|
|
73
|
+
/** Default video model when the caller doesn't pick one. */
|
|
74
|
+
const DEFAULT_VIDEO_MODEL = "fal-ai/veo3/fast";
|
|
75
|
+
/** How often to poll for the async result, and when to give up. Caller-overridable. */
|
|
76
|
+
const DEFAULT_VIDEO_POLL_INTERVAL_MS = 5000;
|
|
77
|
+
const DEFAULT_VIDEO_TIMEOUT_MS = 5 * 60000;
|
|
78
|
+
function mapVideo(raw) {
|
|
79
|
+
return {
|
|
80
|
+
url: raw.url,
|
|
81
|
+
...(raw.content_type !== undefined && { contentType: raw.content_type }),
|
|
82
|
+
...(raw.file_id !== undefined && { fileId: raw.file_id }),
|
|
83
|
+
...(raw.storage_error !== undefined && { storageError: raw.storage_error }),
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
function mapVideoResult(raw) {
|
|
87
|
+
const { video, ...rest } = raw;
|
|
88
|
+
return video === undefined ? { ...rest } : { ...rest, video: mapVideo(video) };
|
|
89
|
+
}
|
|
90
|
+
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
91
|
+
/**
|
|
92
|
+
* Generate a video from a prompt. Video generation is asynchronous: this submits the
|
|
93
|
+
* job, then polls the result through Sapiom until it's ready and returns it — so you
|
|
94
|
+
* `await` it just like {@link createImage}, it just takes longer. Pass `storage` to
|
|
95
|
+
* persist the output (the returned `video` then carries `fileId`). Throws
|
|
96
|
+
* {@link ContentGenerationHttpError} on a failed submit, or an `Error` if the result
|
|
97
|
+
* isn't ready within `timeoutMs`.
|
|
98
|
+
*/
|
|
99
|
+
export async function createVideo(input, transport = defaultTransport(), baseUrl = DEFAULT_BASE_URL) {
|
|
100
|
+
const path = modelToPath(input.model || DEFAULT_VIDEO_MODEL);
|
|
101
|
+
const body = { prompt: input.prompt, ...input.params };
|
|
102
|
+
// Truthy check (not `!== undefined`) so `storage: null` is treated as "no storage".
|
|
103
|
+
if (input.storage)
|
|
104
|
+
body.storage = input.storage;
|
|
105
|
+
// Submit — for an async model Sapiom returns a queue handle, not the result.
|
|
106
|
+
const submitRes = await ensureOk(await transport.fetch(`${baseUrl}/run/${path}`, {
|
|
107
|
+
method: "POST",
|
|
108
|
+
headers: { "content-type": "application/json" },
|
|
109
|
+
body: JSON.stringify(body),
|
|
110
|
+
}), "Failed to submit video generation");
|
|
111
|
+
const handle = (await submitRes.json());
|
|
112
|
+
if (!handle.response_url) {
|
|
113
|
+
throw new Error("Video submit did not return a result URL to poll");
|
|
114
|
+
}
|
|
115
|
+
// Poll the result THROUGH Sapiom until it's ready. The poll is what persists the
|
|
116
|
+
// output when `storage` was requested, so `fileId` is filled in by the time it returns.
|
|
117
|
+
const intervalMs = input.pollIntervalMs ?? DEFAULT_VIDEO_POLL_INTERVAL_MS;
|
|
118
|
+
const timeoutMs = input.timeoutMs ?? DEFAULT_VIDEO_TIMEOUT_MS;
|
|
119
|
+
const deadline = Date.now() + timeoutMs;
|
|
120
|
+
while (Date.now() < deadline) {
|
|
121
|
+
const res = await transport.fetch(handle.response_url, { method: "GET" });
|
|
122
|
+
if (res.ok) {
|
|
123
|
+
const raw = (await res.json());
|
|
124
|
+
if (raw.video?.url)
|
|
125
|
+
return mapVideoResult(raw);
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
// Still generating, or a transient error. Drain the unread body so the
|
|
129
|
+
// connection can be reused, then keep polling — `timeoutMs` is the backstop
|
|
130
|
+
// for a result that never arrives.
|
|
131
|
+
try {
|
|
132
|
+
await res.body?.cancel();
|
|
133
|
+
}
|
|
134
|
+
catch {
|
|
135
|
+
// best-effort drain
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
await sleep(intervalMs);
|
|
139
|
+
}
|
|
140
|
+
throw new Error(`Video generation did not complete within ${timeoutMs}ms (request id: ${handle.request_id ?? "unknown"})`);
|
|
141
|
+
}
|
|
142
|
+
/** The `video` sub-namespace: `contentGeneration.video.create(...)`. Async (submit + poll). */
|
|
143
|
+
export const video = { create: createVideo };
|
|
73
144
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/content-generation/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAa,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AAEnE,OAAO,EAAE,0BAA0B,EAAE,CAAC;AAEtC,MAAM,gBAAgB,GACpB,OAAO,CAAC,GAAG,CAAC,6BAA6B,IAAI,gCAAgC,CAAC;AAEhF,qFAAqF;AACrF,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AA8ElD,SAAS,QAAQ,CAAC,GAAa;IAC7B,OAAO;QACL,GAAG,EAAE,GAAG,CAAC,GAAG;QACZ,GAAG,CAAC,GAAG,CAAC,YAAY,KAAK,SAAS,IAAI,EAAE,WAAW,EAAE,GAAG,CAAC,YAAY,EAAE,CA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|
26
26
|
export * as orchestrations from "./orchestrations/index.js";
|
|
27
27
|
export { ORCHESTRATIONS_RESULT_SIGNAL } from "./orchestrations/index.js";
|
|
28
28
|
export type { OrchestrationRunResultPayload } from "./orchestrations/index.js";
|
|
29
|
-
export { orchestrationResultSchema, OrchestrationResultSchemaError } from "./orchestrations/index.js";
|
|
29
|
+
export { orchestrationResultSchema, OrchestrationResultSchemaError, } from "./orchestrations/index.js";
|
|
30
30
|
export * as fileStorage from "./file-storage/index.js";
|
|
31
31
|
export { FileStorageHttpError } from "./file-storage/index.js";
|
|
32
32
|
export * as contentGeneration from "./content-generation/index.js";
|
|
33
33
|
export { ContentGenerationHttpError } from "./content-generation/index.js";
|
|
34
|
+
export * as search from "./search/index.js";
|
|
35
|
+
export { SearchHttpError } from "./search/index.js";
|
|
34
36
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/esm/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAChE,YAAY,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAC1C,YAAY,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,oBAAoB,CAAC;AAIvE,YAAY,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,KAAK,YAAY,MAAM,yBAAyB,CAAC;AACxD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,KAAK,KAAK,MAAM,kBAAkB,CAAC;AAE1C,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAGxD,YAAY,EACV,mBAAmB,EACnB,uBAA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ACL,yBAAyB,EACzB,8BAA8B,GAC/B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,iBAAiB,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
package/dist/esm/index.js
CHANGED
|
@@ -26,9 +26,11 @@ export * as orchestrations from "./orchestrations/index.js";
|
|
|
26
26
|
// Surfaced top-level for the static `pause: { signal }` decl on a workflow step.
|
|
27
27
|
export { ORCHESTRATIONS_RESULT_SIGNAL } from "./orchestrations/index.js";
|
|
28
28
|
// Validate an OrchestrationRunResultPayload at the resume boundary.
|
|
29
|
-
export { orchestrationResultSchema, OrchestrationResultSchemaError } from "./orchestrations/index.js";
|
|
29
|
+
export { orchestrationResultSchema, OrchestrationResultSchemaError, } from "./orchestrations/index.js";
|
|
30
30
|
export * as fileStorage from "./file-storage/index.js";
|
|
31
31
|
export { FileStorageHttpError } from "./file-storage/index.js";
|
|
32
32
|
export * as contentGeneration from "./content-generation/index.js";
|
|
33
33
|
export { ContentGenerationHttpError } from "./content-generation/index.js";
|
|
34
|
+
export * as search from "./search/index.js";
|
|
35
|
+
export { SearchHttpError } from "./search/index.js";
|
|
34
36
|
//# sourceMappingURL=index.js.map
|
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EAAE,YAAY,EAAE,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAQhE,OAAO,KAAK,SAAS,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,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AAO,EACL,yBAAyB,EACzB,8BAA8B,GAC/B,MAAM,2BAA2B,CAAC;AAEnC,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AACvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,yBAAyB,CAAC;AAE/D,OAAO,KAAK,iBAAiB,MAAM,+BAA+B,CAAC;AACnE,OAAO,EAAE,0BAA0B,EAAE,MAAM,+BAA+B,CAAC;AAE3E,OAAO,KAAK,MAAM,MAAM,mBAAmB,CAAC;AAC5C,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown by the `search` capability when a request fails (non-2xx
|
|
3
|
+
* response). Exposes `status` (HTTP status code) and `body` (parsed JSON body, or
|
|
4
|
+
* raw text when the body isn't JSON) for programmatic inspection.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SearchHttpError extends Error {
|
|
7
|
+
readonly status: number;
|
|
8
|
+
readonly body: unknown;
|
|
9
|
+
constructor(message: string, status: number, body: unknown);
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Return the response when 2xx, otherwise throw a {@link SearchHttpError}.
|
|
13
|
+
* Parses the error body as JSON when possible; falls back to raw text.
|
|
14
|
+
*/
|
|
15
|
+
export declare function ensureOk(response: Response, errorPrefix: string): Promise<Response>;
|
|
16
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../src/search/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,qBAAa,eAAgB,SAAQ,KAAK;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,OAAO,CAAC;gBAEX,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO;CAM3D;AAED;;;GAGG;AACH,wBAAsB,QAAQ,CAC5B,QAAQ,EAAE,QAAQ,EAClB,WAAW,EAAE,MAAM,GAClB,OAAO,CAAC,QAAQ,CAAC,CAcnB"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error thrown by the `search` capability when a request fails (non-2xx
|
|
3
|
+
* response). Exposes `status` (HTTP status code) and `body` (parsed JSON body, or
|
|
4
|
+
* raw text when the body isn't JSON) for programmatic inspection.
|
|
5
|
+
*/
|
|
6
|
+
export class SearchHttpError extends Error {
|
|
7
|
+
constructor(message, status, body) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.name = "SearchHttpError";
|
|
10
|
+
this.status = status;
|
|
11
|
+
this.body = body;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Return the response when 2xx, otherwise throw a {@link SearchHttpError}.
|
|
16
|
+
* Parses the error body as JSON when possible; falls back to raw text.
|
|
17
|
+
*/
|
|
18
|
+
export async function ensureOk(response, errorPrefix) {
|
|
19
|
+
if (response.ok)
|
|
20
|
+
return response;
|
|
21
|
+
let body;
|
|
22
|
+
const text = await response.text().catch(() => "");
|
|
23
|
+
try {
|
|
24
|
+
body = JSON.parse(text);
|
|
25
|
+
}
|
|
26
|
+
catch {
|
|
27
|
+
body = text;
|
|
28
|
+
}
|
|
29
|
+
throw new SearchHttpError(`${errorPrefix}: ${response.status} ${text}`, response.status, body);
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../../src/search/errors.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,OAAO,eAAgB,SAAQ,KAAK;IAIxC,YAAY,OAAe,EAAE,MAAc,EAAE,IAAa;QACxD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;QAC9B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;IACnB,CAAC;CACF;AAED;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,QAAkB,EAClB,WAAmB;IAEnB,IAAI,QAAQ,CAAC,EAAE;QAAE,OAAO,QAAQ,CAAC;IACjC,IAAI,IAAa,CAAC;IAClB,MAAM,IAAI,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,EAAE,CAAC,CAAC;IACnD,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAC1B,CAAC;IAAC,MAAM,CAAC;QACP,IAAI,GAAG,IAAI,CAAC;IACd,CAAC;IACD,MAAM,IAAI,eAAe,CACvB,GAAG,WAAW,KAAK,QAAQ,CAAC,MAAM,IAAI,IAAI,EAAE,EAC5C,QAAQ,CAAC,MAAM,EACf,IAAI,CACL,CAAC;AACJ,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `search` capability — find information across the web and beyond.
|
|
3
|
+
*
|
|
4
|
+
* This is the home for Sapiom's search primitives: searching the web, reading the
|
|
5
|
+
* contents of a page, and looking up professional email addresses. Today it
|
|
6
|
+
* offers `webSearch` (search the web) and `scrape` (read a page); more operations
|
|
7
|
+
* follow.
|
|
8
|
+
*
|
|
9
|
+
* import { search } from "@sapiom/tools"; // ambient auth
|
|
10
|
+
* const hits = await search.webSearch({ query: "what is an LLM agent?" });
|
|
11
|
+
* hits.answer; // a synthesized answer
|
|
12
|
+
* const page = await search.scrape({ url: "https://example.com" });
|
|
13
|
+
* page.markdown; // the page content as markdown
|
|
14
|
+
*
|
|
15
|
+
* Or via an explicit client: `createClient({ apiKey }).search.webSearch(...)`.
|
|
16
|
+
*
|
|
17
|
+
* Failed requests throw {@link SearchHttpError} (carries `status` + parsed `body`).
|
|
18
|
+
*/
|
|
19
|
+
import { Transport } from "../_client/index.js";
|
|
20
|
+
import { SearchHttpError } from "./errors.js";
|
|
21
|
+
export { SearchHttpError };
|
|
22
|
+
/** Output formats `scrape` can return. Defaults to `["markdown"]`. */
|
|
23
|
+
export type ScrapeFormat = "markdown" | "html" | "rawHtml" | "screenshot" | "links";
|
|
24
|
+
export interface ScrapeInput {
|
|
25
|
+
/** URL of the page to read. */
|
|
26
|
+
url: string;
|
|
27
|
+
/** Which content formats to return. Defaults to `["markdown"]`. */
|
|
28
|
+
formats?: ScrapeFormat[];
|
|
29
|
+
/** Return only the main content, dropping nav/header/footer/ads. */
|
|
30
|
+
onlyMainContent?: boolean;
|
|
31
|
+
/** Milliseconds to wait before reading (for content rendered by JavaScript). */
|
|
32
|
+
waitFor?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface ScrapeMetadata {
|
|
35
|
+
/** Page title. */
|
|
36
|
+
title?: string;
|
|
37
|
+
/** Page description. */
|
|
38
|
+
description?: string;
|
|
39
|
+
/** Detected page language. */
|
|
40
|
+
language?: string;
|
|
41
|
+
/** The URL the content was read from. */
|
|
42
|
+
sourceUrl?: string;
|
|
43
|
+
/** HTTP status code returned while reading the page. */
|
|
44
|
+
statusCode?: number;
|
|
45
|
+
}
|
|
46
|
+
export interface ScrapeResult {
|
|
47
|
+
/** The URL that was read (echoes the input). */
|
|
48
|
+
url: string;
|
|
49
|
+
/** Page content as markdown (present when "markdown" was requested). */
|
|
50
|
+
markdown?: string;
|
|
51
|
+
/** Cleaned HTML (present when "html" was requested). */
|
|
52
|
+
html?: string;
|
|
53
|
+
/** Raw HTML (present when "rawHtml" was requested). */
|
|
54
|
+
rawHtml?: string;
|
|
55
|
+
/** Screenshot URL (present when "screenshot" was requested). */
|
|
56
|
+
screenshot?: string;
|
|
57
|
+
/** Links found on the page (present when "links" was requested). */
|
|
58
|
+
links?: string[];
|
|
59
|
+
/** Page metadata (title, description, language, status, …). */
|
|
60
|
+
metadata: ScrapeMetadata;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Read a page and return its content. By default you get markdown; pass `formats`
|
|
64
|
+
* to also (or instead) get HTML, raw HTML, a screenshot, or the page's links.
|
|
65
|
+
*
|
|
66
|
+
* Works on HTML pages and common documents (PDF, DOCX, TXT). Failed requests throw
|
|
67
|
+
* {@link SearchHttpError}.
|
|
68
|
+
*/
|
|
69
|
+
export declare function scrape(input: ScrapeInput, transport?: Transport, baseUrl?: string): Promise<ScrapeResult>;
|
|
70
|
+
export interface WebSearchInput {
|
|
71
|
+
/** What to search for. */
|
|
72
|
+
query: string;
|
|
73
|
+
/** How thoroughly to search. Defaults to `"standard"`. */
|
|
74
|
+
depth?: "standard" | "deep";
|
|
75
|
+
/**
|
|
76
|
+
* What you want back. `"answer"` (default) returns a synthesized answer plus
|
|
77
|
+
* supporting results; `"links"` returns a list of relevant results.
|
|
78
|
+
*/
|
|
79
|
+
intent?: "answer" | "links";
|
|
80
|
+
}
|
|
81
|
+
export interface WebSearchResult {
|
|
82
|
+
/** Result title. */
|
|
83
|
+
title: string;
|
|
84
|
+
/** Result URL. */
|
|
85
|
+
url: string;
|
|
86
|
+
/** Short excerpt for the result. */
|
|
87
|
+
snippet: string;
|
|
88
|
+
}
|
|
89
|
+
export interface WebSearchResponse {
|
|
90
|
+
/** The query that was searched (echoes the input). */
|
|
91
|
+
query: string;
|
|
92
|
+
/** A synthesized answer, when `intent` is `"answer"`. */
|
|
93
|
+
answer?: string;
|
|
94
|
+
/** The results found for the query. */
|
|
95
|
+
results: WebSearchResult[];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Search the web. By default you get a synthesized answer plus supporting
|
|
99
|
+
* results; pass `intent: "links"` for a list of relevant results, and
|
|
100
|
+
* `depth: "deep"` for a more thorough search.
|
|
101
|
+
*
|
|
102
|
+
* Failed requests throw {@link SearchHttpError}.
|
|
103
|
+
*/
|
|
104
|
+
export declare function webSearch(input: WebSearchInput, transport?: Transport, baseUrl?: string): Promise<WebSearchResponse>;
|
|
105
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/search/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EAAE,SAAS,EAAoB,MAAM,qBAAqB,CAAC;AAClE,OAAO,EAAE,eAAe,EAAY,MAAM,aAAa,CAAC;AAExD,OAAO,EAAE,eAAe,EAAE,CAAC;AAU3B,sEAAsE;AACtE,MAAM,MAAM,YAAY,GACpB,UAAU,GACV,MAAM,GACN,SAAS,GACT,YAAY,GACZ,OAAO,CAAC;AAEZ,MAAM,WAAW,WAAW;IAC1B,+BAA+B;IAC/B,GAAG,EAAE,MAAM,CAAC;IACZ,mEAAmE;IACnE,OAAO,CAAC,EAAE,YAAY,EAAE,CAAC;IACzB,oEAAoE;IACpE,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B,gFAAgF;IAChF,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,cAAc;IAC7B,kBAAkB;IAClB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,wBAAwB;IACxB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,8BAA8B;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,yCAAyC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,wDAAwD;IACxD,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,YAAY;IAC3B,gDAAgD;IAChD,GAAG,EAAE,MAAM,CAAC;IACZ,wEAAwE;IACxE,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,wDAAwD;IACxD,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,gEAAgE;IAChE,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,oEAAoE;IACpE,KAAK,CAAC,EAAE,MAAM,EAAE,CAAC;IACjB,+DAA+D;IAC/D,QAAQ,EAAE,cAAc,CAAC;CAC1B;AAkED;;;;;;GAMG;AACH,wBAAsB,MAAM,CAC1B,KAAK,EAAE,WAAW,EAClB,SAAS,GAAE,SAA8B,EACzC,OAAO,SAAmB,GACzB,OAAO,CAAC,YAAY,CAAC,CAkBvB;AAID,MAAM,WAAW,cAAc;IAC7B,0BAA0B;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,0DAA0D;IAC1D,KAAK,CAAC,EAAE,UAAU,GAAG,MAAM,CAAC;IAC5B;;;OAGG;IACH,MAAM,CAAC,EAAE,QAAQ,GAAG,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,eAAe;IAC9B,oBAAoB;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,kBAAkB;IAClB,GAAG,EAAE,MAAM,CAAC;IACZ,oCAAoC;IACpC,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,iBAAiB;IAChC,sDAAsD;IACtD,KAAK,EAAE,MAAM,CAAC;IACd,yDAAyD;IACzD,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,OAAO,EAAE,eAAe,EAAE,CAAC;CAC5B;AAyCD;;;;;;GAMG;AACH,wBAAsB,SAAS,CAC7B,KAAK,EAAE,cAAc,EACrB,SAAS,GAAE,SAA8B,EACzC,OAAO,SAA8B,GACpC,OAAO,CAAC,iBAAiB,CAAC,CAsB5B"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `search` capability — find information across the web and beyond.
|
|
3
|
+
*
|
|
4
|
+
* This is the home for Sapiom's search primitives: searching the web, reading the
|
|
5
|
+
* contents of a page, and looking up professional email addresses. Today it
|
|
6
|
+
* offers `webSearch` (search the web) and `scrape` (read a page); more operations
|
|
7
|
+
* follow.
|
|
8
|
+
*
|
|
9
|
+
* import { search } from "@sapiom/tools"; // ambient auth
|
|
10
|
+
* const hits = await search.webSearch({ query: "what is an LLM agent?" });
|
|
11
|
+
* hits.answer; // a synthesized answer
|
|
12
|
+
* const page = await search.scrape({ url: "https://example.com" });
|
|
13
|
+
* page.markdown; // the page content as markdown
|
|
14
|
+
*
|
|
15
|
+
* Or via an explicit client: `createClient({ apiKey }).search.webSearch(...)`.
|
|
16
|
+
*
|
|
17
|
+
* Failed requests throw {@link SearchHttpError} (carries `status` + parsed `body`).
|
|
18
|
+
*/
|
|
19
|
+
import { defaultTransport } from "../_client/index.js";
|
|
20
|
+
import { SearchHttpError, ensureOk } from "./errors.js";
|
|
21
|
+
export { SearchHttpError };
|
|
22
|
+
const DEFAULT_BASE_URL = process.env.SAPIOM_SCRAPE_URL || "https://firecrawl.services.sapiom.ai";
|
|
23
|
+
const DEFAULT_WEB_SEARCH_BASE_URL = process.env.SAPIOM_SEARCH_URL || "https://api.sapiom.ai";
|
|
24
|
+
/** Collapse a field that may be a single value or an array down to one value. */
|
|
25
|
+
function firstOf(value) {
|
|
26
|
+
return Array.isArray(value) ? value[0] : value;
|
|
27
|
+
}
|
|
28
|
+
function mapMetadata(raw) {
|
|
29
|
+
const meta = raw ?? {};
|
|
30
|
+
const title = firstOf(meta.title);
|
|
31
|
+
const description = firstOf(meta.description);
|
|
32
|
+
// A field a caller didn't ask for comes back null — treat null as absent (`!=`)
|
|
33
|
+
// so the result only carries fields that were actually populated.
|
|
34
|
+
return {
|
|
35
|
+
...(title != null && { title }),
|
|
36
|
+
...(description != null && { description }),
|
|
37
|
+
...(meta.language != null && { language: meta.language }),
|
|
38
|
+
...(meta.sourceURL != null && { sourceUrl: meta.sourceURL }),
|
|
39
|
+
...(meta.statusCode != null && { statusCode: meta.statusCode }),
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function mapScrape(url, raw) {
|
|
43
|
+
const data = raw.data ?? {};
|
|
44
|
+
// Unrequested formats come back null; treat null as absent (`!=`) so each
|
|
45
|
+
// format field is present only when it was actually returned.
|
|
46
|
+
return {
|
|
47
|
+
url,
|
|
48
|
+
...(data.markdown != null && { markdown: data.markdown }),
|
|
49
|
+
...(data.html != null && { html: data.html }),
|
|
50
|
+
...(data.rawHtml != null && { rawHtml: data.rawHtml }),
|
|
51
|
+
...(data.screenshot != null && { screenshot: data.screenshot }),
|
|
52
|
+
...(data.links != null && { links: data.links }),
|
|
53
|
+
metadata: mapMetadata(data.metadata),
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
// ----- Capability operations -----
|
|
57
|
+
/**
|
|
58
|
+
* Read a page and return its content. By default you get markdown; pass `formats`
|
|
59
|
+
* to also (or instead) get HTML, raw HTML, a screenshot, or the page's links.
|
|
60
|
+
*
|
|
61
|
+
* Works on HTML pages and common documents (PDF, DOCX, TXT). Failed requests throw
|
|
62
|
+
* {@link SearchHttpError}.
|
|
63
|
+
*/
|
|
64
|
+
export async function scrape(input, transport = defaultTransport(), baseUrl = DEFAULT_BASE_URL) {
|
|
65
|
+
// `!= null` so an optional explicitly passed as null (a JS caller bypassing the
|
|
66
|
+
// types) is treated as absent rather than forwarded as a null field.
|
|
67
|
+
const body = { url: input.url };
|
|
68
|
+
if (input.formats != null)
|
|
69
|
+
body.formats = input.formats;
|
|
70
|
+
if (input.onlyMainContent != null)
|
|
71
|
+
body.onlyMainContent = input.onlyMainContent;
|
|
72
|
+
if (input.waitFor != null)
|
|
73
|
+
body.waitFor = input.waitFor;
|
|
74
|
+
const res = await ensureOk(await transport.fetch(`${baseUrl}/v2/scrape`, {
|
|
75
|
+
method: "POST",
|
|
76
|
+
headers: { "content-type": "application/json" },
|
|
77
|
+
body: JSON.stringify(body),
|
|
78
|
+
}), "Failed to scrape");
|
|
79
|
+
return mapScrape(input.url, (await res.json()));
|
|
80
|
+
}
|
|
81
|
+
function mapWebSearchResult(raw) {
|
|
82
|
+
return {
|
|
83
|
+
title: raw.title ?? "",
|
|
84
|
+
url: raw.url ?? "",
|
|
85
|
+
snippet: raw.snippet ?? "",
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function mapWebSearch(query, raw) {
|
|
89
|
+
// Build the result from only the public fields. A defensive measure: any
|
|
90
|
+
// extra top-level field on the wire (e.g. bookkeeping not meant for callers)
|
|
91
|
+
// is dropped by construction rather than spread through.
|
|
92
|
+
const results = Array.isArray(raw.results)
|
|
93
|
+
? raw.results.map(mapWebSearchResult)
|
|
94
|
+
: [];
|
|
95
|
+
return {
|
|
96
|
+
query: raw.query ?? query,
|
|
97
|
+
...(raw.answer != null && { answer: raw.answer }),
|
|
98
|
+
results,
|
|
99
|
+
};
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Search the web. By default you get a synthesized answer plus supporting
|
|
103
|
+
* results; pass `intent: "links"` for a list of relevant results, and
|
|
104
|
+
* `depth: "deep"` for a more thorough search.
|
|
105
|
+
*
|
|
106
|
+
* Failed requests throw {@link SearchHttpError}.
|
|
107
|
+
*/
|
|
108
|
+
export async function webSearch(input, transport = defaultTransport(), baseUrl = DEFAULT_WEB_SEARCH_BASE_URL) {
|
|
109
|
+
// `!= null` so an optional explicitly passed as null (a JS caller bypassing the
|
|
110
|
+
// types) is treated as absent rather than forwarded as a null field.
|
|
111
|
+
const body = {
|
|
112
|
+
query: input.query,
|
|
113
|
+
intent: input.intent ?? "answer",
|
|
114
|
+
};
|
|
115
|
+
if (input.depth != null)
|
|
116
|
+
body.depth = input.depth;
|
|
117
|
+
const res = await ensureOk(await transport.fetch(`${baseUrl}/v1/capabilities/web.search`, {
|
|
118
|
+
method: "POST",
|
|
119
|
+
headers: { "content-type": "application/json" },
|
|
120
|
+
body: JSON.stringify(body),
|
|
121
|
+
}, { authHeader: "x-api-key" }), "Failed to search the web");
|
|
122
|
+
return mapWebSearch(input.query, (await res.json()));
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/search/index.ts"],"names":[],"mappings":"AAAA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;IAErC,gFAAgF;IAChF,qEAAqE;IACrE,MAAM,IAAI,GAA4B;QACpC,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,MAAM,EAAE,KAAK,CAAC,MAAM,IAAI,QAAQ;KACjC,CAAC;IACF,IAAI,KAAK,CAAC,KAAK,IAAI,IAAI;QAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC;IAElD,MAAM,GAAG,GAAG,MAAM,QAAQ,CACxB,MAAM,SAAS,CAAC,KAAK,CACnB,GAAG,OAAO,6BAA6B,EACvC;QACE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE,EAAE,cAAc,EAAE,kBAAkB,EAAE;QAC/C,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;KAC3B,EACD,EAAE,UAAU,EAAE,WAAW,EAAE,CAC5B,EACD,0BAA0B,CAC3B,CAAC;IACF,OAAO,YAAY,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAyB,CAAC,CAAC;AAC/E,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stub/index.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/stub/index.ts"],"names":[],"mappings":"AA2BA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAe3C,4EAA4E;AAC5E,MAAM,MAAM,aAAa,GAAG,MAAM,CAChC,MAAM,EACN,OAAO,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC,CAC5C,CAAC;AAEF,MAAM,WAAW,iBAAiB;IAChC,SAAS,CAAC,EAAE,aAAa,CAAC;IAC1B;;;;;OAKG;IACH,OAAO,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/B;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;IACvB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;CACxB;AA0TD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,GAAE,iBAAsB,GAAG,MAAM,CA0PrE"}
|
package/dist/esm/stub/index.js
CHANGED
|
@@ -315,7 +315,10 @@ export function createStubClient(opts = {}) {
|
|
|
315
315
|
};
|
|
316
316
|
const handle = {
|
|
317
317
|
executionId,
|
|
318
|
-
dispatch: {
|
|
318
|
+
dispatch: {
|
|
319
|
+
correlationId: executionId,
|
|
320
|
+
resultSignal: ORCHESTRATIONS_RESULT_SIGNAL,
|
|
321
|
+
},
|
|
319
322
|
status: () => Promise.resolve("completed"),
|
|
320
323
|
wait: () => Promise.resolve(result),
|
|
321
324
|
};
|
|
@@ -374,6 +377,41 @@ export function createStubClient(opts = {}) {
|
|
|
374
377
|
],
|
|
375
378
|
}))),
|
|
376
379
|
},
|
|
380
|
+
video: {
|
|
381
|
+
create: (input) => Promise.resolve(r("contentGeneration.video.create", [input], () => ({
|
|
382
|
+
video: {
|
|
383
|
+
url: "https://content.local/stub-video.mp4",
|
|
384
|
+
contentType: "video/mp4",
|
|
385
|
+
// mirror the real stitch: a fileId only when storage was requested.
|
|
386
|
+
...(input.storage ? { fileId: "stub-file" } : {}),
|
|
387
|
+
},
|
|
388
|
+
}))),
|
|
389
|
+
},
|
|
390
|
+
},
|
|
391
|
+
search: {
|
|
392
|
+
scrape: (input) => Promise.resolve(r("search.scrape", [input], () => ({
|
|
393
|
+
url: input.url,
|
|
394
|
+
markdown: `# ${input.url}\n\n(stub) scraped content`,
|
|
395
|
+
metadata: {
|
|
396
|
+
title: "Stub Page",
|
|
397
|
+
sourceUrl: input.url,
|
|
398
|
+
statusCode: 200,
|
|
399
|
+
},
|
|
400
|
+
}))),
|
|
401
|
+
webSearch: (input) => Promise.resolve(r("search.webSearch", [input], () => ({
|
|
402
|
+
query: input.query,
|
|
403
|
+
// mirror the real shape: an answer for the default intent, omitted for "links".
|
|
404
|
+
...(input.intent === "links"
|
|
405
|
+
? {}
|
|
406
|
+
: { answer: `(stub) answer for "${input.query}"` }),
|
|
407
|
+
results: [
|
|
408
|
+
{
|
|
409
|
+
title: "Stub Result",
|
|
410
|
+
url: "https://example.com",
|
|
411
|
+
snippet: `(stub) result for "${input.query}"`,
|
|
412
|
+
},
|
|
413
|
+
],
|
|
414
|
+
}))),
|
|
377
415
|
},
|
|
378
416
|
withAttribution: () => client,
|
|
379
417
|
};
|