OUTPUT #934 | 3537 karakter | 78 satır
========== YENİ KOMUT | 21.09.2026 22:13:12 ==========
========== YENİ KOMUT | 21.09.2026 22:13:12 ==========
* requestBody:
* required: true
* content:
* application/json:
* schema:
* type: object
* required: [userId, path]
* properties:
* userId:
* type: string
* path:
* description: "Absolute path, or array of paths, that resolves within CAMOFOX_UPLOADS_DIR."
* oneOf:
* - type: string
* - type: array
* items:
* type: string
* ref:
* type: string
* description: "Trigger element ref (e.g. e36). Optional when an input[type=file] already exists."
* selector:
* type: string
* description: "Trigger element CSS/Playwright selector. Optional when an input[type=file] already exists."
* timeout:
* type: integer
* default: 12000
* description: "Overall budget in ms to wait for an upload UI (in-app panel input or native file chooser) to appear after the trigger is activated. Ignored values (non-numeric or <= 0) fall back to the default."
* responses:
* 200:
* description: "File(s) attached."
* 400:
* description: "Bad request (missing path/userId; non-regular file; or a path that is missing or outside the configured upload directory)."
* 404:
* description: "Tab not found."
*/
app.post('/tabs/:tabId/upload', async (req, res) => {
const tabId = req.params.tabId;
try {
const { userId, ref, selector } = req.body;
const { path: filePath } = req.body;
const uploadTimeout = Number.isFinite(req.body.timeout) && req.body.timeout > 0
? req.body.timeout
: UPLOAD_UI_TIMEOUT_MS;
if (!userId) return res.status(400).json({ error: 'userId required' });
if (!filePath) return res.status(400).json({ error: 'path required (container-side file path)' });
const paths = await resolveUploadPaths({ uploadsDir: CONFIG.uploadsDir, filePaths: Array.isArray(filePath) ? filePath : [filePath] });
const session = sessions.get(normalizeUserId(userId));
const found = session && findTab(session, tabId);
if (!found) return tabNotFoundResponse(res, req.params.tabId || req.body?.tabId);
session.lastAccess = Date.now();
const { tabState } = found;
tabState.toolCalls++; tabState.consecutiveTimeouts = 0; tabState.consecutiveFailures = 0;
const result = await withUserLimit(userId, () => withTabLock(tabId, async () => {
const directInput = tabState.page.locator('input[type="file"]').first();
let attachedVia = null;
const trySetExistingInput = async () => {
try {
if (await directInput.count() > 0) {
await directInput.setInputFiles(paths, { timeout: UPLOAD_INPUT_TIMEOUT_MS });
return true;
}
} catch (e) {
log('info', 'upload: setInputFiles on existing input failed', { error: e.message });
}
return false;
};
// Strategy 1: an <input type=file> already exists right now (an upload
// panel was opened before this call) -> set files directly. setInputFiles
root@213-238-170-219:/home/hermes/.hermes/hermes-agent#