@agent-tool-calls/machine 0.1.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/dist/index.d.ts +11 -0
- package/dist/index.js +48 -0
- package/dist/index.js.map +1 -0
- package/dist/mac.d.ts +11 -0
- package/dist/mac.js +45 -0
- package/dist/mac.js.map +1 -0
- package/dist/types.d.ts +20 -0
- package/dist/types.js +3 -0
- package/dist/types.js.map +1 -0
- package/dist/windows.d.ts +9 -0
- package/dist/windows.js +16 -0
- package/dist/windows.js.map +1 -0
- package/package.json +37 -0
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @agent-tool-calls/machine — cross-platform OS operations.
|
|
3
|
+
*
|
|
4
|
+
* Real Mac implementation + Windows stub. Platform is selected at runtime.
|
|
5
|
+
* No Timmy or AI-framework imports — this stays a plain, reusable library.
|
|
6
|
+
*/
|
|
7
|
+
import type { MachineAdapter } from './types';
|
|
8
|
+
export * from './types';
|
|
9
|
+
export type Platform = 'mac' | 'windows' | 'linux';
|
|
10
|
+
export declare function currentPlatform(): Platform;
|
|
11
|
+
export declare function createMachine(): MachineAdapter;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* @agent-tool-calls/machine — cross-platform OS operations.
|
|
4
|
+
*
|
|
5
|
+
* Real Mac implementation + Windows stub. Platform is selected at runtime.
|
|
6
|
+
* No Timmy or AI-framework imports — this stays a plain, reusable library.
|
|
7
|
+
*/
|
|
8
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
9
|
+
if (k2 === undefined) k2 = k;
|
|
10
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
11
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
12
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
13
|
+
}
|
|
14
|
+
Object.defineProperty(o, k2, desc);
|
|
15
|
+
}) : (function(o, m, k, k2) {
|
|
16
|
+
if (k2 === undefined) k2 = k;
|
|
17
|
+
o[k2] = m[k];
|
|
18
|
+
}));
|
|
19
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
20
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
21
|
+
};
|
|
22
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
+
exports.currentPlatform = currentPlatform;
|
|
24
|
+
exports.createMachine = createMachine;
|
|
25
|
+
const mac_1 = require("./mac");
|
|
26
|
+
const windows_1 = require("./windows");
|
|
27
|
+
__exportStar(require("./types"), exports);
|
|
28
|
+
function currentPlatform() {
|
|
29
|
+
switch (process.platform) {
|
|
30
|
+
case 'win32':
|
|
31
|
+
return 'windows';
|
|
32
|
+
case 'darwin':
|
|
33
|
+
return 'mac';
|
|
34
|
+
default:
|
|
35
|
+
return 'linux';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
function createMachine() {
|
|
39
|
+
switch (process.platform) {
|
|
40
|
+
case 'win32':
|
|
41
|
+
return new windows_1.WindowsAdapter();
|
|
42
|
+
case 'darwin':
|
|
43
|
+
return new mac_1.MacAdapter();
|
|
44
|
+
default:
|
|
45
|
+
throw new Error(`@agent-tool-calls/machine: platform '${process.platform}' is not supported yet (only macOS; Windows stub lands in Phase 11)`);
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;;;;;;;;;;;;;;;AAUH,0CASC;AAED,sCAWC;AA9BD,+BAAkC;AAClC,uCAA0C;AAG1C,0CAAuB;AAIvB,SAAgB,eAAe;IAC7B,QAAQ,OAAO,CAAC,QAAQ,EAAE,CAAC;QACzB,KAAK,OAAO;YACV,OAAO,SAAS,CAAA;QAClB,KAAK,QAAQ;YACX,OAAO,KAAK,CAAA;QACd;YACE,OAAO,OAAO,CAAA;IAClB,CAAC;AACH,CAAC;AAED,SAAgB,aAAa;IAC3B,QAAQ,OAAO,CAAC,QAAQ,EAAE,CAAC;QACzB,KAAK,OAAO;YACV,OAAO,IAAI,wBAAc,EAAE,CAAA;QAC7B,KAAK,QAAQ;YACX,OAAO,IAAI,gBAAU,EAAE,CAAA;QACzB;YACE,MAAM,IAAI,KAAK,CACb,wCAAwC,OAAO,CAAC,QAAQ,qEAAqE,CAC9H,CAAA;IACL,CAAC;AACH,CAAC"}
|
package/dist/mac.d.ts
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { FileEntry, MachineAdapter, ProcessInfo, Runner } from './types';
|
|
2
|
+
export declare class MacAdapter implements MachineAdapter {
|
|
3
|
+
private readonly run;
|
|
4
|
+
constructor(run?: Runner);
|
|
5
|
+
openApp(name: string): Promise<void>;
|
|
6
|
+
playMedia(uri: string): Promise<void>;
|
|
7
|
+
listDirectory(path: string): Promise<FileEntry[]>;
|
|
8
|
+
deleteFile(path: string): Promise<void>;
|
|
9
|
+
killProcess(pid: number): Promise<void>;
|
|
10
|
+
getRunningProcesses(): Promise<ProcessInfo[]>;
|
|
11
|
+
}
|
package/dist/mac.js
ADDED
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MacAdapter = void 0;
|
|
4
|
+
const promises_1 = require("node:fs/promises");
|
|
5
|
+
const node_child_process_1 = require("node:child_process");
|
|
6
|
+
const node_util_1 = require("node:util");
|
|
7
|
+
const defaultRunner = async (cmd, args) => {
|
|
8
|
+
const { stdout } = await (0, node_util_1.promisify)(node_child_process_1.execFile)(cmd, args);
|
|
9
|
+
return { stdout };
|
|
10
|
+
};
|
|
11
|
+
class MacAdapter {
|
|
12
|
+
run;
|
|
13
|
+
constructor(run = defaultRunner) {
|
|
14
|
+
this.run = run;
|
|
15
|
+
}
|
|
16
|
+
async openApp(name) {
|
|
17
|
+
await this.run('open', ['-a', name]);
|
|
18
|
+
}
|
|
19
|
+
async playMedia(uri) {
|
|
20
|
+
await this.run('open', [uri]);
|
|
21
|
+
}
|
|
22
|
+
async listDirectory(path) {
|
|
23
|
+
const ents = await (0, promises_1.readdir)(path, { withFileTypes: true });
|
|
24
|
+
return ents.map((e) => ({ name: e.name, isDirectory: e.isDirectory() }));
|
|
25
|
+
}
|
|
26
|
+
async deleteFile(path) {
|
|
27
|
+
await (0, promises_1.rm)(path);
|
|
28
|
+
}
|
|
29
|
+
async killProcess(pid) {
|
|
30
|
+
process.kill(pid);
|
|
31
|
+
}
|
|
32
|
+
async getRunningProcesses() {
|
|
33
|
+
const { stdout } = await this.run('ps', ['-axo', 'pid=,comm=']);
|
|
34
|
+
return stdout
|
|
35
|
+
.trim()
|
|
36
|
+
.split('\n')
|
|
37
|
+
.map((line) => {
|
|
38
|
+
const m = line.trim().match(/^(\d+)\s+(.*)$/);
|
|
39
|
+
return m ? { pid: Number(m[1]), name: m[2] } : null;
|
|
40
|
+
})
|
|
41
|
+
.filter((p) => p !== null);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.MacAdapter = MacAdapter;
|
|
45
|
+
//# sourceMappingURL=mac.js.map
|
package/dist/mac.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mac.js","sourceRoot":"","sources":["../src/mac.ts"],"names":[],"mappings":";;;AAAA,+CAA8C;AAC9C,2DAA6C;AAC7C,yCAAqC;AAGrC,MAAM,aAAa,GAAW,KAAK,EAAE,GAAG,EAAE,IAAI,EAAE,EAAE;IAChD,MAAM,EAAE,MAAM,EAAE,GAAG,MAAM,IAAA,qBAAS,EAAC,6BAAQ,CAAC,CAAC,GAAG,EAAE,IAAI,CAAC,CAAA;I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CAAC,KAAK,CAAC,gBAAgB,CAAC,CAAA;YAC7C,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAA;QACrD,CAAC,CAAC;aACD,MAAM,CAAC,CAAC,CAAC,EAAoB,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC,CAAA;IAChD,CAAC;CACF;AAnCD,gCAmCC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export interface FileEntry {
|
|
2
|
+
name: string;
|
|
3
|
+
isDirectory: boolean;
|
|
4
|
+
}
|
|
5
|
+
export interface ProcessInfo {
|
|
6
|
+
pid: number;
|
|
7
|
+
name: string;
|
|
8
|
+
}
|
|
9
|
+
/** Injectable shell runner so adapters are unit-testable without real side effects. */
|
|
10
|
+
export type Runner = (cmd: string, args: string[]) => Promise<{
|
|
11
|
+
stdout: string;
|
|
12
|
+
}>;
|
|
13
|
+
export interface MachineAdapter {
|
|
14
|
+
openApp(name: string): Promise<void>;
|
|
15
|
+
playMedia(uri: string): Promise<void>;
|
|
16
|
+
listDirectory(path: string): Promise<FileEntry[]>;
|
|
17
|
+
deleteFile(path: string): Promise<void>;
|
|
18
|
+
killProcess(pid: number): Promise<void>;
|
|
19
|
+
getRunningProcesses(): Promise<ProcessInfo[]>;
|
|
20
|
+
}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { MachineAdapter } from './types';
|
|
2
|
+
export declare class WindowsAdapter implements MachineAdapter {
|
|
3
|
+
openApp: () => Promise<never>;
|
|
4
|
+
playMedia: () => Promise<never>;
|
|
5
|
+
listDirectory: () => Promise<never>;
|
|
6
|
+
deleteFile: () => Promise<never>;
|
|
7
|
+
killProcess: () => Promise<never>;
|
|
8
|
+
getRunningProcesses: () => Promise<never>;
|
|
9
|
+
}
|
package/dist/windows.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WindowsAdapter = void 0;
|
|
4
|
+
const ni = (op) => async () => {
|
|
5
|
+
throw new Error(`WindowsAdapter.${op} not implemented (Phase 11 Windows port)`);
|
|
6
|
+
};
|
|
7
|
+
class WindowsAdapter {
|
|
8
|
+
openApp = ni('openApp');
|
|
9
|
+
playMedia = ni('playMedia');
|
|
10
|
+
listDirectory = ni('listDirectory');
|
|
11
|
+
deleteFile = ni('deleteFile');
|
|
12
|
+
killProcess = ni('killProcess');
|
|
13
|
+
getRunningProcesses = ni('getRunningProcesses');
|
|
14
|
+
}
|
|
15
|
+
exports.WindowsAdapter = WindowsAdapter;
|
|
16
|
+
//# sourceMappingURL=windows.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"windows.js","sourceRoot":"","sources":["../src/windows.ts"],"names":[],"mappings":";;;AAEA,MAAM,EAAE,GAAG,CAAC,EAAU,EAAE,EAAE,CAAC,KAAK,IAAoB,EAAE;IACpD,MAAM,IAAI,KAAK,CAAC,kBAAkB,EAAE,0CAA0C,CAAC,CAAA;AACjF,CAAC,CAAA;AAED,MAAa,cAAc;IACzB,OAAO,GAAG,EAAE,CAAC,SAAS,CAAC,CAAA;IACvB,SAAS,GAAG,EAAE,CAAC,WAAW,CAAC,CAAA;IAC3B,aAAa,GAAG,EAAE,CAAC,eAAe,CAAC,CAAA;IACnC,UAAU,GAAG,EAAE,CAAC,YAAY,CAAC,CAAA;IAC7B,WAAW,GAAG,EAAE,CAAC,aAAa,CAAC,CAAA;IAC/B,mBAAmB,GAAG,EAAE,CAAC,qBAAqB,CAAC,CAAA;CAChD;AAPD,wCAOC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@agent-tool-calls/machine",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Cross-platform OS operations — open apps, play media, list/delete files, manage processes",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"os",
|
|
7
|
+
"automation",
|
|
8
|
+
"agent",
|
|
9
|
+
"tools",
|
|
10
|
+
"macos"
|
|
11
|
+
],
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/omatsetyadi/agent-tool-calls.git",
|
|
16
|
+
"directory": "packages/machine"
|
|
17
|
+
},
|
|
18
|
+
"homepage": "https://github.com/omatsetyadi/agent-tool-calls#readme",
|
|
19
|
+
"main": "dist/index.js",
|
|
20
|
+
"types": "dist/index.d.ts",
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/node": "^24.0.0",
|
|
29
|
+
"typescript": "^6.0.0",
|
|
30
|
+
"vitest": "^3.2.6"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "tsc -p tsconfig.json",
|
|
34
|
+
"typecheck": "tsc -p tsconfig.json --noEmit",
|
|
35
|
+
"test": "vitest run"
|
|
36
|
+
}
|
|
37
|
+
}
|