Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: UTIO (UI-TARS Insights and Observation) #8

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"@electron-toolkit/utils": "^3.0.0",
"@ui-tars/action-parser": "workspace:*",
"@ui-tars/shared": "workspace:*",
"@ui-tars/utio": "workspace:*",
"async-retry": "^1.3.3",
"big.js": "^6.2.2",
"dotenv": "^16.4.7",
Expand Down
30 changes: 30 additions & 0 deletions packages/utio/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"name": "@ui-tars/utio",
"version": "1.0.0",
"description": "UTIO (UI-TARS Insights and Observation)",
"main": "./dist/index.js",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"scripts": {
"prepare": "npm run build",
"dev": "tsup --watch",
"build": "tsup",
"prepack": "npm run build"
},
"keywords": [
"UI-TARS"
],
"license": "Apache-2.0",
"publishConfig": {
"registry": "https://registry.npmjs.org/"
},
"files": [
"dist",
"src"
],
"dependencies": {},
"devDependencies": {
"tsup": "^8.3.5",
"typescript": "^5.7.2"
}
}
27 changes: 27 additions & 0 deletions packages/utio/src/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { UTIOPayload, UTIOType } from './types';

export type { UTIOPayload };

export class UTIO {
constructor(private readonly endpoint: string) {}

async send<T extends UTIOType>(data: UTIOPayload<T>): Promise<void> {
if (!this.endpoint) return;

try {
const response = await fetch(this.endpoint, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(data),
});

if (!response.ok) {
throw new Error(`UTIO upload failed with status: ${response.status}`);
}
} catch (error) {
// Silent fail
}
}
}
41 changes: 41 additions & 0 deletions packages/utio/src/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* Copyright (c) 2025 Bytedance, Inc. and its affiliates.
* SPDX-License-Identifier: Apache-2.0
*/

export type UTIOType = 'appLaunched' | 'sendInstruction' | 'shareReport';

export interface UTIOBasePayload {
instruction: string;
}

export type UTIOPayloadMap = {
/**
* The application is opened
*/
appLaunched: {
type: 'appLaunched';
platform: string;
osVersion: string;
screenWidth: number;
screenHeight: number;
};
/**
* User sent instruction
*/
sendInstruction: {
type: 'sendInstruction';
instruction: string;
};
/**
* Share report
*/
shareReport: UTIOBasePayload & {
type: 'shareReport';
lastScreenshot?: string;
report?: string;
instruction: string;
};
};

export type UTIOPayload<T extends UTIOType> = UTIOPayloadMap[T];
19 changes: 19 additions & 0 deletions packages/utio/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"target": "esnext",
"module": "esnext",
"moduleResolution": "Bundler",
"declaration": true,
"declarationMap": true,
"sourceMap": true,
"outDir": "./dist",
"strict": true,
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"resolveJsonModule": true,
"isolatedModules": true,
"skipLibCheck": true
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
}
16 changes: 16 additions & 0 deletions packages/utio/tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
/**
* Copyright (c) 2025 Bytedance, Inc. and its affiliates.
* SPDX-License-Identifier: Apache-2.0
*/
import { defineConfig } from 'tsup';

export default defineConfig((options) => {
return {
entry: ['src/**/*.ts'],
format: ['esm', 'cjs'],
dts: true,
clean: true,
bundle: false,
outDir: 'dist',
};
});
85 changes: 41 additions & 44 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading