orangeslice 1.8.0 → 1.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/api.js +7 -13
- package/dist/cli.js +16 -7
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ Orangeslice provides a `services.*` API for B2B research, enrichment, scraping,
|
|
|
8
8
|
npx orangeslice
|
|
9
9
|
```
|
|
10
10
|
|
|
11
|
-
The CLI copies docs to `./orangeslice-docs
|
|
11
|
+
The CLI copies docs to `./orangeslice-docs`, creates `./orangeslice-docs/AGENTS.md`, initializes `package.json` when missing, and installs `orangeslice` in the current directory.
|
|
12
12
|
|
|
13
13
|
Install as a dependency when writing app code:
|
|
14
14
|
|
package/dist/api.js
CHANGED
|
@@ -4,21 +4,19 @@ exports.BATCH_NATIVE_FUNCTION_IDS = void 0;
|
|
|
4
4
|
exports.getFunctionType = getFunctionType;
|
|
5
5
|
exports.getBridgeResultEventName = getBridgeResultEventName;
|
|
6
6
|
exports.post = post;
|
|
7
|
-
const crypto_1 = require("crypto");
|
|
8
7
|
/**
|
|
9
8
|
* Runtime routing:
|
|
10
9
|
* - Non-direct calls submit to Railway batch-service /function
|
|
11
10
|
* - Direct calls submit to orangeslice.ai /api/function
|
|
12
11
|
* - Pending polling splits by function type:
|
|
13
|
-
* -
|
|
14
|
-
* - bridge: poll Next.js bridge-result route
|
|
12
|
+
* - default: poll batch-service /function/result
|
|
13
|
+
* - bridge: poll Next.js bridge-result route only when backend provides bridge metadata
|
|
15
14
|
*/
|
|
16
15
|
const BASE_URL = "https://enrichly-production.up.railway.app/function";
|
|
17
16
|
const DIRECT_BASE_URL = "https://orangeslice.ai/api/function";
|
|
18
17
|
const BRIDGE_POLL_URL = "https://orangeslice.ai/api/function/bridge-result";
|
|
19
18
|
const POLL_TIMEOUT_MS = 120000;
|
|
20
19
|
const DEFAULT_POLL_INTERVAL_MS = 1000;
|
|
21
|
-
const INTERNAL_CALLBACK_ID_KEY = "_orangesliceCallbackEventId";
|
|
22
20
|
exports.BATCH_NATIVE_FUNCTION_IDS = new Set(["b2b", "batchserp", "generateObject"]);
|
|
23
21
|
const BRIDGE_RESULT_EVENT_BY_FUNCTION_ID = {
|
|
24
22
|
firecrawl: "proxy/firecrawl.result",
|
|
@@ -161,11 +159,8 @@ async function pollBridgeUntilComplete(functionId, callbackEventId, eventName, f
|
|
|
161
159
|
async function post(functionId, payload, options = {}) {
|
|
162
160
|
const baseUrl = options.direct ? DIRECT_BASE_URL : BASE_URL;
|
|
163
161
|
const functionType = options.direct ? "batch-native" : getFunctionType(functionId);
|
|
164
|
-
const bridgeEventName = getBridgeResultEventName(functionId);
|
|
165
|
-
const callbackEventId = functionType === "bridge" && !options.direct && bridgeEventName ? (0, crypto_1.randomUUID)() : undefined;
|
|
166
|
-
const requestPayload = callbackEventId && functionType === "bridge" ? { ...payload, [INTERNAL_CALLBACK_ID_KEY]: callbackEventId } : payload;
|
|
167
162
|
const url = `${baseUrl}?functionId=${functionId}`;
|
|
168
|
-
const body = JSON.stringify(
|
|
163
|
+
const body = JSON.stringify(payload);
|
|
169
164
|
const res = await fetchWithRedirect(url, {
|
|
170
165
|
method: "POST",
|
|
171
166
|
headers: { "Content-Type": "application/json" },
|
|
@@ -181,12 +176,11 @@ async function post(functionId, payload, options = {}) {
|
|
|
181
176
|
if (isPendingResponse(data)) {
|
|
182
177
|
if (functionType === "bridge") {
|
|
183
178
|
const bridgePending = data;
|
|
184
|
-
const resolvedCallbackId = bridgePending.callbackEventId
|
|
185
|
-
const resolvedEventName = bridgePending.eventName ||
|
|
186
|
-
if (
|
|
187
|
-
|
|
179
|
+
const resolvedCallbackId = bridgePending.callbackEventId;
|
|
180
|
+
const resolvedEventName = bridgePending.eventName || getBridgeResultEventName(functionId);
|
|
181
|
+
if (resolvedCallbackId && resolvedEventName) {
|
|
182
|
+
return pollBridgeUntilComplete(functionId, resolvedCallbackId, resolvedEventName, bridgePending.pollAfterMs);
|
|
188
183
|
}
|
|
189
|
-
return pollBridgeUntilComplete(functionId, resolvedCallbackId, resolvedEventName, bridgePending.pollAfterMs);
|
|
190
184
|
}
|
|
191
185
|
return pollBatchUntilComplete(baseUrl, functionId, data);
|
|
192
186
|
}
|
package/dist/cli.js
CHANGED
|
@@ -99,6 +99,17 @@ Use the docs in this folder as the source of truth for all orangeslice operation
|
|
|
99
99
|
`;
|
|
100
100
|
fs.writeFileSync(AGENTS_FILE, content, "utf8");
|
|
101
101
|
}
|
|
102
|
+
function ensurePackageJson(cwd) {
|
|
103
|
+
const packageJsonPath = path.join(cwd, "package.json");
|
|
104
|
+
if (fs.existsSync(packageJsonPath))
|
|
105
|
+
return;
|
|
106
|
+
console.log(" No package.json found. Initializing npm project...");
|
|
107
|
+
(0, child_process_1.execSync)("npm init -y", { stdio: "inherit", cwd });
|
|
108
|
+
}
|
|
109
|
+
function installOrangeslice(cwd) {
|
|
110
|
+
console.log(" Installing orangeslice...");
|
|
111
|
+
(0, child_process_1.execSync)("npm install orangeslice", { stdio: "inherit", cwd });
|
|
112
|
+
}
|
|
102
113
|
async function main() {
|
|
103
114
|
console.log("\norangeslice\n");
|
|
104
115
|
const docsDir = resolveDocsDir();
|
|
@@ -108,13 +119,11 @@ async function main() {
|
|
|
108
119
|
copyDirSync(docsDir, TARGET_DIR);
|
|
109
120
|
writeAgentsGuide(TARGET_DIR);
|
|
110
121
|
console.log(` ✓ Docs (${path.basename(docsDir)}) → ./orangeslice-docs/\n`);
|
|
111
|
-
//
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
// no package.json or npm not available
|
|
117
|
-
}
|
|
122
|
+
// Always set up package installation in the current directory.
|
|
123
|
+
const cwd = process.cwd();
|
|
124
|
+
ensurePackageJson(cwd);
|
|
125
|
+
installOrangeslice(cwd);
|
|
126
|
+
console.log(" ✓ Package installed in current directory\n");
|
|
118
127
|
console.log("\nReady - services-style API\n");
|
|
119
128
|
console.log(" import { services } from 'orangeslice';\n");
|
|
120
129
|
console.log(" Agent setup (do this first):");
|