agi 0.3.0 → 0.4.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/README.md CHANGED
@@ -21,7 +21,7 @@
21
21
 
22
22
  ---
23
23
 
24
- **AI agent that actually works on the web.**
24
+ **Universal Computer-Use AI**
25
25
 
26
26
  <br />
27
27
 
@@ -352,6 +352,79 @@ const session = await client.createSession('agi-0', {
352
352
 
353
353
  </details>
354
354
 
355
+ <details>
356
+ <summary><b>Client-Driven Sessions</b> – Run agents on desktop, mobile, or custom environments</summary>
357
+
358
+ <br />
359
+
360
+ > **Note:** Desktop mode is currently feature-gated. For enterprise access, contact [`partner@theagi.company`](mailto:partner@theagi.company).
361
+
362
+ For scenarios where you control the execution environment (desktop automation, mobile apps, custom browsers), use client-driven sessions with `AgentLoop`:
363
+
364
+ ```typescript
365
+ import { AGIClient, AgentLoop } from 'agi';
366
+
367
+ const client = new AGIClient({ apiKey: process.env.AGI_API_KEY });
368
+
369
+ // Create a client-driven session
370
+ const session = await client.sessions.create('agi-2-claude', {
371
+ agentSessionType: 'desktop',
372
+ goal: 'Open calculator and compute 2+2',
373
+ });
374
+
375
+ // Create and run the loop
376
+ const loop = new AgentLoop({
377
+ client,
378
+ agentUrl: session.agentUrl!,
379
+ captureScreenshot: async () => {
380
+ // Return base64-encoded screenshot from your environment
381
+ return '...';
382
+ },
383
+ executeActions: async (actions) => {
384
+ for (const action of actions) {
385
+ console.log(`Executing: ${action.type}`);
386
+ // Execute action in your environment
387
+ }
388
+ },
389
+ onThinking: (t) => console.log(`💭 ${t}`),
390
+ });
391
+
392
+ const result = await loop.start();
393
+ console.log(`Finished: ${result.finished}`);
394
+ ```
395
+
396
+ **Loop Control:**
397
+
398
+ ```typescript
399
+ // Start without awaiting
400
+ const promise = loop.start();
401
+
402
+ // Pause/resume/stop
403
+ loop.pause(); // Pause after current step
404
+ loop.resume(); // Continue execution
405
+ loop.stop(); // Stop the loop
406
+
407
+ // Check state
408
+ loop.state; // 'running', 'paused', 'stopped', 'finished'
409
+ loop.currentStep; // Current step number
410
+ loop.lastResult; // Last StepDesktopResponse
411
+ ```
412
+
413
+ **Manual Step Control:**
414
+
415
+ ```typescript
416
+ // Or manage the loop yourself
417
+ let finished = false;
418
+ while (!finished) {
419
+ const screenshot = await captureScreenshot();
420
+ const result = await client.sessions.step(session.agentUrl!, screenshot);
421
+ await executeActions(result.actions);
422
+ finished = result.finished;
423
+ }
424
+ ```
425
+
426
+ </details>
427
+
355
428
  ---
356
429
 
357
430
  ## Error Handling