agenttwin 0.1.0 → 0.2.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.
Files changed (121) hide show
  1. package/README.md +85 -27
  2. package/dist/api.js +659 -0
  3. package/dist/cli.js +5165 -57
  4. package/dist/dashboard/assets/brand.css +2 -0
  5. package/dist/dashboard/assets/dashboard/dashboard.css +184 -0
  6. package/dist/dashboard/assets/dashboard/dashboard.js +421 -0
  7. package/dist/dashboard/assets/dashboard/hosted.js +45 -0
  8. package/dist/dashboard/assets/dashboard/inventory.json +1 -0
  9. package/dist/dashboard/assets/dashboard/runs.json +1 -0
  10. package/dist/dashboard/assets/fonts/Syne-OFL.txt +93 -0
  11. package/dist/dashboard/assets/fonts/inter-var.woff2 +0 -0
  12. package/dist/dashboard/assets/fonts/plexmono-400.woff2 +0 -0
  13. package/dist/dashboard/assets/fonts/plexmono-500.woff2 +0 -0
  14. package/dist/dashboard/assets/fonts/syne-400.ttf +0 -0
  15. package/dist/dashboard/assets/fonts/syne-500.ttf +0 -0
  16. package/dist/dashboard/assets/fonts/syne-600.ttf +0 -0
  17. package/dist/dashboard/assets/icons/ATTRIBUTION.md +7 -0
  18. package/dist/dashboard/assets/icons/attio.ico +0 -0
  19. package/dist/dashboard/assets/icons/aws.svg +1 -0
  20. package/dist/dashboard/assets/icons/bank.svg +5 -0
  21. package/dist/dashboard/assets/icons/box.svg +1 -0
  22. package/dist/dashboard/assets/icons/chat.svg +3 -0
  23. package/dist/dashboard/assets/icons/check.png +0 -0
  24. package/dist/dashboard/assets/icons/ci.svg +5 -0
  25. package/dist/dashboard/assets/icons/clay.png +0 -0
  26. package/dist/dashboard/assets/icons/cloudflare.svg +1 -0
  27. package/dist/dashboard/assets/icons/co-abridge.png +0 -0
  28. package/dist/dashboard/assets/icons/co-clay.png +0 -0
  29. package/dist/dashboard/assets/icons/co-cognition.png +0 -0
  30. package/dist/dashboard/assets/icons/co-intercom.svg +1 -0
  31. package/dist/dashboard/assets/icons/co-paloalto.png +0 -0
  32. package/dist/dashboard/assets/icons/co-pylon.png +0 -0
  33. package/dist/dashboard/assets/icons/co-ramp.png +0 -0
  34. package/dist/dashboard/assets/icons/co-sentry.svg +1 -0
  35. package/dist/dashboard/assets/icons/codes.svg +5 -0
  36. package/dist/dashboard/assets/icons/datadog.svg +1 -0
  37. package/dist/dashboard/assets/icons/discord.svg +1 -0
  38. package/dist/dashboard/assets/icons/docker.svg +1 -0
  39. package/dist/dashboard/assets/icons/documenso.png +0 -0
  40. package/dist/dashboard/assets/icons/dropbox.svg +1 -0
  41. package/dist/dashboard/assets/icons/edr.svg +4 -0
  42. package/dist/dashboard/assets/icons/ehr.svg +5 -0
  43. package/dist/dashboard/assets/icons/git.svg +1 -0
  44. package/dist/dashboard/assets/icons/github.svg +1 -0
  45. package/dist/dashboard/assets/icons/githubactions.svg +1 -0
  46. package/dist/dashboard/assets/icons/gitlab.svg +1 -0
  47. package/dist/dashboard/assets/icons/gmail.svg +7 -0
  48. package/dist/dashboard/assets/icons/google-calendar.svg +28 -0
  49. package/dist/dashboard/assets/icons/google.svg +1 -0
  50. package/dist/dashboard/assets/icons/googlecloud.svg +1 -0
  51. package/dist/dashboard/assets/icons/googledocs.svg +1 -0
  52. package/dist/dashboard/assets/icons/googledrive.svg +1 -0
  53. package/dist/dashboard/assets/icons/googlesheets.svg +1 -0
  54. package/dist/dashboard/assets/icons/hubspot.svg +1 -0
  55. package/dist/dashboard/assets/icons/intercom.svg +1 -0
  56. package/dist/dashboard/assets/icons/jira.svg +1 -0
  57. package/dist/dashboard/assets/icons/klaviyo.png +0 -0
  58. package/dist/dashboard/assets/icons/kubernetes.svg +1 -0
  59. package/dist/dashboard/assets/icons/linear.svg +1 -0
  60. package/dist/dashboard/assets/icons/linkedin.svg +1 -0
  61. package/dist/dashboard/assets/icons/mail.svg +4 -0
  62. package/dist/dashboard/assets/icons/mixpanel.svg +1 -0
  63. package/dist/dashboard/assets/icons/mongodb.svg +1 -0
  64. package/dist/dashboard/assets/icons/netsuite.png +0 -0
  65. package/dist/dashboard/assets/icons/nodedotjs.svg +1 -0
  66. package/dist/dashboard/assets/icons/notes.svg +5 -0
  67. package/dist/dashboard/assets/icons/notion.svg +1 -0
  68. package/dist/dashboard/assets/icons/npm.svg +1 -0
  69. package/dist/dashboard/assets/icons/okta.svg +1 -0
  70. package/dist/dashboard/assets/icons/openai.svg +1 -0
  71. package/dist/dashboard/assets/icons/outlook.ico +0 -0
  72. package/dist/dashboard/assets/icons/pagerduty.svg +1 -0
  73. package/dist/dashboard/assets/icons/policy.svg +5 -0
  74. package/dist/dashboard/assets/icons/postgres.svg +1 -0
  75. package/dist/dashboard/assets/icons/python.svg +1 -0
  76. package/dist/dashboard/assets/icons/quickbooks.svg +1 -0
  77. package/dist/dashboard/assets/icons/redis.svg +1 -0
  78. package/dist/dashboard/assets/icons/resend.svg +1 -0
  79. package/dist/dashboard/assets/icons/salesforce.svg +1 -0
  80. package/dist/dashboard/assets/icons/sentry.svg +1 -0
  81. package/dist/dashboard/assets/icons/shopify.svg +1 -0
  82. package/dist/dashboard/assets/icons/siem.svg +4 -0
  83. package/dist/dashboard/assets/icons/slack.svg +6 -0
  84. package/dist/dashboard/assets/icons/snowflake.svg +1 -0
  85. package/dist/dashboard/assets/icons/sparkle.svg +4 -0
  86. package/dist/dashboard/assets/icons/stripe.svg +1 -0
  87. package/dist/dashboard/assets/icons/supabase.svg +1 -0
  88. package/dist/dashboard/assets/icons/terraform.svg +1 -0
  89. package/dist/dashboard/assets/icons/trolley.ico +0 -0
  90. package/dist/dashboard/assets/icons/twilio.svg +1 -0
  91. package/dist/dashboard/assets/icons/ui/arrow-right.svg +1 -0
  92. package/dist/dashboard/assets/icons/ui/arrows-clockwise.svg +1 -0
  93. package/dist/dashboard/assets/icons/ui/arrows-left-right.svg +1 -0
  94. package/dist/dashboard/assets/icons/ui/caret-down.svg +1 -0
  95. package/dist/dashboard/assets/icons/ui/check.svg +1 -0
  96. package/dist/dashboard/assets/icons/ui/clock.svg +1 -0
  97. package/dist/dashboard/assets/icons/ui/cube.svg +1 -0
  98. package/dist/dashboard/assets/icons/ui/git-branch.svg +1 -0
  99. package/dist/dashboard/assets/icons/ui/github-logo.svg +1 -0
  100. package/dist/dashboard/assets/icons/ui/magnifying-glass.svg +1 -0
  101. package/dist/dashboard/assets/icons/ui/plugs-connected.svg +1 -0
  102. package/dist/dashboard/assets/icons/ui/seal-check.svg +1 -0
  103. package/dist/dashboard/assets/icons/ui/shield-check.svg +1 -0
  104. package/dist/dashboard/assets/icons/ui/stack-simple.svg +1 -0
  105. package/dist/dashboard/assets/icons/ui/terminal.svg +1 -0
  106. package/dist/dashboard/assets/icons/ui/warning-circle.svg +1 -0
  107. package/dist/dashboard/assets/icons/ui/x.svg +1 -0
  108. package/dist/dashboard/assets/icons/unified.png +0 -0
  109. package/dist/dashboard/assets/icons/unified.svg +23 -0
  110. package/dist/dashboard/assets/icons/unstructured.svg +3 -0
  111. package/dist/dashboard/assets/icons/vercel.svg +1 -0
  112. package/dist/dashboard/assets/icons/waterfall.jpg +0 -0
  113. package/dist/dashboard/assets/icons/xero.svg +1 -0
  114. package/dist/dashboard/assets/logo/favicon.svg +7 -0
  115. package/dist/dashboard/assets/logo/mark-stacked-worlds.svg +4 -0
  116. package/dist/dashboard/assets/logo/mark-twin-rings.svg +7 -0
  117. package/dist/dashboard/assets/logo/mark-worlds-overlap.svg +10 -0
  118. package/dist/dashboard/index.html +64 -0
  119. package/dist/gateway.js +666 -0
  120. package/dist/worker.js +341 -0
  121. package/package.json +8 -3
package/README.md CHANGED
@@ -1,48 +1,106 @@
1
- # agenttwin
1
+ # AgentTwin
2
2
 
3
- **Give your agent a test world before it touches the real one.**
3
+ Discover a project's dependencies, then run an explicitly configured Node workflow in a fresh hosted sandbox with stateful service adapters, faults and final-state checks.
4
4
 
5
- A safe, executable copy of the systems your agent reads from and writes to, so you
6
- can run the same workflow against a replica, inject real failure conditions, and
7
- turn a discovered failure into a regression test.
5
+ AgentTwin 0.2.0 executes application code in E2B. No local application containers are required. The E2B key belongs to the runtime operator; users of the hosted API receive separate revocable AgentTwin tokens.
8
6
 
9
- > **Early preview.** This package is the CLI shell for that vision. `agenttwin init`
10
- > works today. The runtime commands (`up`, `run`, `fault`, `diff`, `adopt`) are
11
- > coming soon.
7
+ ## Install and discover
12
8
 
13
- ## Usage
9
+ Node.js 22+ is required. Run discovery from your project; npx installs the CLI automatically:
14
10
 
15
11
  ```sh
12
+ npm install --no-save --ignore-scripts /path/to/agenttwin-0.2.0.tgz
16
13
  npx agenttwin init
14
+ npx agenttwin example --out ./agenttwin-example
17
15
  ```
18
16
 
19
- Writes a starter `agenttwin.config.json` into the current directory:
17
+ `init` writes the inventory, workflow candidates, `agenttwin.config.json`, `ENVIRONMENT.md`, `REPLICATION.md`, and an offline browser report. Discovery is evidence, not an automatically executable environment. It never uploads source. `init --json --dry-run` writes nothing.
20
18
 
21
- ```json
22
- {
23
- "version": 1,
24
- "world": "default",
25
- "twins": []
26
- }
19
+ ## Run through an AgentTwin API
20
+
21
+ Your operator supplies the API URL and your individual token:
22
+
23
+ ```sh
24
+ export AGENTTWIN_API_URL=https://your-agenttwin-api.example.com
25
+ export AGENTTWIN_TOKEN=your_individual_token
26
+ npx agenttwin run --file agenttwin-example/agenttwin.world.json
27
+ npx agenttwin run --file agenttwin-example/safe.world.json
27
28
  ```
28
29
 
29
- Re-run with `--force` to overwrite an existing config.
30
+ The first run should fail: a write commits but its response is delayed, and an unsafe retry creates two tickets. The safe version reuses an idempotency key and passes. Both execute real application code against a custom ticket API and a bounded Slack adapter. Every run starts from fresh seeds and credentials, then deletes its sandbox. These are examples you can replace, not a refund-specific product.
31
+
32
+ `run --json` emits a receipt with source/spec hashes, application output, ordered service events, initial/final service state, assertions, fault activation and sandbox metadata. Evidence stays in `.agenttwin/runs/`. Exit codes: 0 passed; 1 failed/error; 2 incomplete/blocked; 3 invalid input. An unsupported adapter operation or an untriggered requested fault makes the run incomplete.
33
+
34
+ ## Use your own E2B account
30
35
 
31
36
  ```sh
32
- npx agenttwin --help
33
- npx agenttwin --version
37
+ export E2B_API_KEY=your_key
38
+ npx agenttwin setup
39
+ npx agenttwin run --runtime e2b --file agenttwin-example/safe.world.json
34
40
  ```
35
41
 
36
- ## Requirements
42
+ `setup` builds a Node 22/PostgreSQL 15/Redis template on E2B and stores its nonsecret ID in `~/.agenttwin/runtime.json`. `E2B_TEMPLATE_ID` overrides that ID. It creates no local Docker containers. Sandboxes are created only for runs. The runtime boundary permits adding another hosted provider later; only E2B is implemented today.
43
+
44
+ ## Run your code
45
+
46
+ Edit a world JSON file, listing only the built application files to upload. Bundle npm dependencies before the run; the sandbox has no outbound internet and performs no npm install. `command` is an argv array starting with `node`; the app runs as uid 1000. A world file resolves its application files relative to its own directory. Optional `workflowId` links to a workflow in the current discovery inventory.
47
+
48
+ Use the generated `AGENTTWIN_<SERVICE>_URL` and `AGENTTWIN_<SERVICE>_TOKEN` values to configure your test clients. Production accounts, OAuth sessions, `.env` files and host credentials are not copied. Tokens and service state are fresh per run. Source files may contain hardcoded secrets; review the explicit upload list and bundle before uploading it.
49
+
50
+ Supported now:
51
+
52
+ - Generic JSON collections: GET/list, POST/create, seed records, bearer authentication and same-key idempotency replay/conflict. This is a custom API contract, not a CRM vendor clone.
53
+ - Slack subset: `chat.postMessage` with channel/text, `conversations.list` without parameters, `conversations.history` with channel. JSON and form POSTs are supported; reads also accept GET. Unknown methods or parameters fail visibly. OAuth, pagination, threads, files and complete SDK/provider parity are not supported.
54
+ - Real PostgreSQL 15: optional seed SQL, generated `DATABASE_URL`, read-only SELECT final-state assertions.
55
+ - Real Redis: generated `REDIS_URL`/`REDISCLI_AUTH`, string-key final-state assertions.
56
+ - One fault: a committed HTTP write followed by a delayed response. State count/filter assertions, DB rows and Redis values can verify side effects.
57
+
58
+ There is no automatic cloning of arbitrary software, provider account provisioning, complete vendor catalog, browser workflow runtime, coordinated snapshots, replay of LLM responses or automatic regression-code generation. Receipts verify the configured assertions, not complete production equivalence or adversarial program correctness.
59
+
60
+ ## Discovery and reports
37
61
 
38
- Node.js 18 or newer.
62
+ `discover`, `decide`, `plan`, `status`, `inspect`, `grant`, `schema`, `export`, `report`, and `feedback` remain available. `--json` sends results to stdout and logs to stderr. Discovery inspects files and bounded commands; remote reads require scoped grants. `--probe` explicitly requests provider reads. Local application observation and the legacy refund `demo/trial/check/reset` commands are retired in the public CLI; use hosted `run` instead. Development unit tests still exercise adapter code locally.
39
63
 
40
- ## Status
64
+ ## Operate the API
41
65
 
42
- `agenttwin init` is the only implemented command. Nothing here connects to real
43
- providers, requests credentials, or executes code. See the project repository for
44
- the product thesis and roadmap.
66
+ The package includes `dist/gateway.js`. Deploy it on a server with Node 22+, HTTPS ingress and persistent disk. See the repository's `docs/HOSTED-RUNTIME.md` for deployment, accounts, limits and operational boundaries. The gateway is a control plane; applications execute in separate E2B sandboxes.
67
+
68
+ MIT license.
69
+
70
+ ## Discovery dashboard
71
+
72
+ `agenttwin init --yes` detects project dependencies, tooling and available connector configuration, then writes `.agenttwin/dashboard/index.html`. Open that file to review the detected environment without selecting every connector or uploading inventory. The dashboard includes its assets and an allowlisted discovery payload; account records, credential values and evidence paths are excluded. It starts with no saved run receipts. Detection does not verify provider access or implement an adapter.
73
+
74
+ For this repository’s website preview (`python3 serve.py 4173`), the dashboard automatically loads the latest handoff from init every five seconds while visible. Other projects use their generated dashboard or the manual discovery import. No inventory is uploaded to a hosted website automatically. Removed detected resources stay excluded until a fresh init scan.
75
+
76
+ ## Prepare an actual discovered workflow
77
+
78
+ After `init`, select a candidate from `.agenttwin/inventory.json` or the dashboard's New world view. Write `preparation.json` beside your application files:
79
+
80
+ ```json
81
+ {
82
+ "schema": "agenttwin/preparation-v1",
83
+ "workflowId": "YOUR_DISCOVERED_WORKFLOW_ID",
84
+ "world": {
85
+ "schema": "agenttwin/world-v1",
86
+ "name": "notification",
87
+ "files": ["workflow.mjs"],
88
+ "command": ["node", "workflow.mjs"],
89
+ "timeoutSeconds": 20,
90
+ "services": [{"name":"slack","adapter":"slack","collections":[{"path":"/messages","seed":[]},{"path":"/channels","seed":[{"id":"C_TEST","name":"test"}]}]}],
91
+ "assertions": [{"service":"slack","path":"/messages","count":1}]
92
+ },
93
+ "mappings": [{"toolId":"YOUR_DISCOVERED_SLACK_TOOL_ID","service":"slack","contract":"slack","operations":["chat.postMessage"],"reviewed":true}]
94
+ }
95
+ ```
96
+
97
+ Use your actual discovered IDs and include every operation recorded for the candidate. Configure code to use the generated `AGENTTWIN_SLACK_URL` and `AGENTTWIN_SLACK_TOKEN`; an SDK needs its base URL overridden. The runtime does not install dependencies or transpile source: include a built, self-contained Node entrypoint and every required application file. Preparation never executes your code.
98
+
99
+ ```sh
100
+ npx agenttwin prepare --file preparation.json --out .agenttwin/prepared/notification
101
+ npx agenttwin run --file .agenttwin/prepared/notification/agenttwin.world.json
102
+ ```
45
103
 
46
- ## License
104
+ The output contains your unchanged source, a world spec, a SHA-256 manifest, and `agenttwin.bundle.json`. In Hosted runs, connect with an individual API token, choose that bundle, review the upload and execute. Jobs can be refreshed, cancelled and inspected. Tokens stay in page memory. Discovery imports remain in the browser; executing uploads the explicit bundle to the API.
47
105
 
48
- MIT
106
+ Supported mapping contracts: bounded Slack operations, PostgreSQL, Redis and custom JSON collections (`GET /path` / `POST /path`). Preparation rejects missing/unreviewed mappings and unsupported vendor SDK operations. Discovery and mappings remain user-reviewed declarations, not proof that every operation or dependency in arbitrary source was discovered. Hosted execution checks the declared assertions.