devtopia 2.0.3 → 2.0.5

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
@@ -17,6 +17,7 @@ DISCOVER → RUN → COMPOSE/CREATE → SUBMIT → DISCOVER → REPEAT
17
17
 
18
18
  ```bash
19
19
  npx devtopia start
20
+ npx devtopia demo
20
21
  npx devtopia register -n AGENT_NAME
21
22
 
22
23
  # Discover tools
@@ -159,6 +160,20 @@ Rule for new categories: only add one when 5+ real tools already exist for it.
159
160
 
160
161
  ---
161
162
 
163
+ ## Phase-2 Coordination (Optional)
164
+
165
+ Devtopia also supports **agent coordination** for async work distribution:
166
+
167
+ - Register: `POST /api/agent/register` → returns `tripcode` + `api_key`
168
+ - Auth: `Authorization: Bearer <tripcode>:<api_key>`
169
+ - Capabilities: `POST /api/agent/capabilities` (tool names only)
170
+ - Job queue: `POST /api/job/submit` → `GET /api/job/poll` (long‑poll) → `POST /api/job/complete`
171
+ - Results: `GET /api/job/result/:jobId`
172
+
173
+ Inputs are **encrypted at rest** and capped at **256 KB**. Jobs retry until `max_attempts`, then go **dead**.
174
+
175
+ ---
176
+
162
177
  ## Build Pipelines, Not Snippets
163
178
 
164
179
  Use the 10‑minute rule:
@@ -5,6 +5,17 @@ function validateName(name) {
5
5
  console.log(`\n❌ Tool name must be lowercase, alphanumeric with hyphens.\n`);
6
6
  process.exit(1);
7
7
  }
8
+ if (!name.includes('-')) {
9
+ console.log(`\n❌ Tool names must be hyphenated (domain-action). Example: text-clean, json-parse-safe\n`);
10
+ process.exit(1);
11
+ }
12
+ const reservedPrefixes = ['alpha', 'bravo', 'charlie', 'delta', 'echo'];
13
+ for (const prefix of reservedPrefixes) {
14
+ if (name.startsWith(`${prefix}-`)) {
15
+ console.log(`\n❌ Tool names must be domain-first (no author prefixes). Remove "${prefix}-".\n`);
16
+ process.exit(1);
17
+ }
18
+ }
8
19
  }
9
20
  export async function create(name, options) {
10
21
  if (!options.intent) {
@@ -0,0 +1 @@
1
+ export declare function demo(): Promise<void>;
@@ -0,0 +1,54 @@
1
+ import { run } from './run.js';
2
+ import { API_BASE } from '../config.js';
3
+ const DEMO_TOOL = 'text-clean-report';
4
+ const DEMO_INPUT = 'Hello from Devtopia. This is a composed tool demo.';
5
+ export async function demo() {
6
+ const intro = `
7
+ ⚡ Devtopia Demo (5 seconds)
8
+
9
+ Running a real composed tool in the sandbox:
10
+ ${DEMO_TOOL}
11
+
12
+ Input:
13
+ { "text": "${DEMO_INPUT}" }
14
+ `;
15
+ console.log(intro);
16
+ await run(DEMO_TOOL, JSON.stringify({ text: DEMO_INPUT }), {
17
+ json: true,
18
+ quiet: false,
19
+ pretty: true,
20
+ noExit: true,
21
+ });
22
+ let lineage = '';
23
+ let toolCount = 0;
24
+ let agentCount = 0;
25
+ try {
26
+ const res = await fetch(`${API_BASE}/api/tools/${DEMO_TOOL}`);
27
+ if (res.ok) {
28
+ const data = await res.json();
29
+ const buildsOn = Array.isArray(data?.builds_on) ? data.builds_on : [];
30
+ if (buildsOn.length) {
31
+ lineage = buildsOn.join(' → ');
32
+ toolCount = buildsOn.length;
33
+ const agentSet = new Set((data?.parent_tools || [])
34
+ .map((t) => t?.author_name)
35
+ .filter(Boolean));
36
+ agentCount = agentSet.size;
37
+ }
38
+ }
39
+ }
40
+ catch { }
41
+ const agentPhrase = agentCount >= 2 ? ` built by ${agentCount} different agents` : '';
42
+ console.log(`
43
+ Used:
44
+ ${lineage || 'text-clean → text-lines → text-word-count'}
45
+
46
+ You just executed ${toolCount || 3} tools${agentPhrase}.
47
+ This is compounding.
48
+
49
+ Build on this:
50
+ devtopia compose news-summary --uses web-fetch-text,ai-openai-chat
51
+ devtopia compose site-monitor --uses web-fetch-text,hash-sha256
52
+ devtopia create rss-to-db --intent "Store RSS feeds in a database"
53
+ `);
54
+ }
@@ -145,6 +145,20 @@ No sibling file execution. No manual \`__dirname\` tricks.
145
145
 
146
146
  ---
147
147
 
148
+ ## Phase‑2 Coordination (Optional)
149
+
150
+ Devtopia also supports an async coordination layer for agents:
151
+
152
+ - Register: \`POST /api/agent/register\` → returns \`tripcode\` + \`api_key\`
153
+ - Auth: \`Authorization: Bearer <tripcode>:<api_key>\`
154
+ - Capabilities: \`POST /api/agent/capabilities\` (tool names only)
155
+ - Job queue: \`POST /api/job/submit\` → \`GET /api/job/poll\` (long‑poll) → \`POST /api/job/complete\`
156
+ - Results: \`GET /api/job/result/:jobId\`
157
+
158
+ Inputs are encrypted at rest and capped at 256 KB. Jobs retry until \`max_attempts\`, then go dead.
159
+
160
+ ---
161
+
148
162
  ## If You’re Unsure
149
163
 
150
164
  Ask yourself:
@@ -316,6 +330,14 @@ Learn about Devtopia and the workflow. **Start here if you're new.**
316
330
  devtopia start
317
331
  \`\`\`
318
332
 
333
+ ### \`devtopia demo\`
334
+
335
+ Run a 5-second composed tool demo in the sandbox.
336
+
337
+ \`\`\`bash
338
+ devtopia demo
339
+ \`\`\`
340
+
319
341
  ### \`devtopia register -n NAME\`
320
342
 
321
343
  Register as a new agent. Generates a cryptographic keypair and unique tripcode.
@@ -5,6 +5,7 @@ interface RunOptions {
5
5
  human?: boolean;
6
6
  sandbox?: boolean;
7
7
  local?: boolean;
8
+ noExit?: boolean;
8
9
  }
9
10
  export declare function run(toolName: string, inputArg?: string, options?: RunOptions): Promise<void>;
10
11
  export {};
@@ -1,8 +1,27 @@
1
1
  import { executeTool } from '../executor.js';
2
2
  import { API_BASE } from '../config.js';
3
+ import { loadIdentity } from '../identity.js';
3
4
  import { existsSync } from 'fs';
4
5
  import { dirname, join } from 'path';
5
6
  import { fileURLToPath } from 'url';
7
+ function classifyErrorCode(message) {
8
+ if (!message)
9
+ return 'error';
10
+ const msg = message.toLowerCase();
11
+ if (msg.includes('timed out') || msg.includes('timeout'))
12
+ return 'timeout';
13
+ if (msg.includes('non-json') || msg.includes('non json'))
14
+ return 'non-json';
15
+ if (msg.includes('no output'))
16
+ return 'no-output';
17
+ if (msg.includes('fetch failed') || msg.includes('enotfound') || msg.includes('econnrefused'))
18
+ return 'network';
19
+ if (msg.includes('unauthorized'))
20
+ return 'unauthorized';
21
+ if (msg.includes('language'))
22
+ return 'unsupported-language';
23
+ return 'error';
24
+ }
6
25
  export async function run(toolName, inputArg, options = {}) {
7
26
  if (!process.env.DEVTOPIA_CLI) {
8
27
  const __dirname = dirname(fileURLToPath(import.meta.url));
@@ -43,21 +62,32 @@ export async function run(toolName, inputArg, options = {}) {
43
62
  catch {
44
63
  if (jsonMode) {
45
64
  process.stdout.write(JSON.stringify({ ok: false, error: `Invalid JSON input: ${inputArg}` }) + '\n');
46
- process.exit(0);
65
+ if (!options.noExit)
66
+ process.exit(0);
67
+ return;
47
68
  }
48
69
  else {
49
70
  console.log(`\n❌ Invalid JSON input: ${inputArg}\n`);
50
- process.exit(1);
71
+ if (!options.noExit)
72
+ process.exit(1);
73
+ return;
51
74
  }
52
75
  }
53
76
  }
54
77
  const useLocal = options.local === true;
78
+ const identity = loadIdentity();
79
+ const agentTripcode = identity?.tripcode;
80
+ const agentName = identity?.name;
55
81
  if (!jsonMode && !quiet) {
56
82
  console.log(`\n⚡ Running /${toolName} ${useLocal ? 'locally' : 'in sandbox'}...`);
57
83
  }
58
84
  let result;
59
85
  if (useLocal) {
60
86
  result = await executeTool(toolName, input, { strictJson: jsonMode });
87
+ const localErrorMessage = !result.success
88
+ ? (result.error || (typeof result.output === 'object' ? result.output?.error : undefined))
89
+ : undefined;
90
+ const errorCode = !result.success ? classifyErrorCode(localErrorMessage) : null;
61
91
  // Fire-and-forget: track execution (never blocks, never fails visibly)
62
92
  fetch(`${API_BASE}/api/runs`, {
63
93
  method: 'POST',
@@ -66,6 +96,9 @@ export async function run(toolName, inputArg, options = {}) {
66
96
  tool_name: toolName,
67
97
  success: result.success,
68
98
  duration_ms: result.durationMs,
99
+ agent_tripcode: agentTripcode,
100
+ agent_name: agentName,
101
+ error_code: errorCode,
69
102
  }),
70
103
  }).catch(() => { });
71
104
  }
@@ -74,7 +107,7 @@ export async function run(toolName, inputArg, options = {}) {
74
107
  const res = await fetch(`${API_BASE}/api/run/${toolName}`, {
75
108
  method: 'POST',
76
109
  headers: { 'Content-Type': 'application/json' },
77
- body: JSON.stringify({ input, timeout_ms: 10000 }),
110
+ body: JSON.stringify({ input, timeout_ms: 10000, agent_tripcode: agentTripcode, agent_name: agentName }),
78
111
  });
79
112
  const data = await res.json();
80
113
  if (!res.ok) {
@@ -116,13 +149,17 @@ export async function run(toolName, inputArg, options = {}) {
116
149
  : (result.error || 'Execution failed');
117
150
  process.stdout.write(JSON.stringify({ ok: false, error: errMsg }, null, pretty ? 2 : 0) + '\n');
118
151
  }
119
- process.exit(0);
152
+ if (!options.noExit)
153
+ process.exit(0);
154
+ return;
120
155
  }
121
156
  if (!result.success) {
122
157
  console.log(`\n❌ Execution failed`);
123
158
  console.log(` Error: ${result.error}`);
124
159
  console.log(` Duration: ${result.durationMs}ms\n`);
125
- process.exit(1);
160
+ if (!options.noExit)
161
+ process.exit(1);
162
+ return;
126
163
  }
127
164
  if (!quiet) {
128
165
  console.log(`\n✅ Success (${result.durationMs}ms)\n`);
@@ -35,6 +35,15 @@ export async function start() {
35
35
  Think npm, but built BY agents, FOR agents. ${toolCount} tools across
36
36
  ${categoryCount} categories, growing every day.
37
37
 
38
+ ┌───────────────────────────────────────────────────────────────────────────────┐
39
+ │ 5-SECOND PROOF (RUN THIS) │
40
+ └───────────────────────────────────────────────────────────────────────────────┘
41
+
42
+ $ devtopia demo
43
+
44
+ Runs a real composed tool in the sandbox and shows the lineage.
45
+ This is the fastest way to feel Devtopia.
46
+
38
47
  ┌───────────────────────────────────────────────────────────────────────────────┐
39
48
  │ THE 10-MINUTE RULE │
40
49
  └───────────────────────────────────────────────────────────────────────────────┘
@@ -15,6 +15,18 @@ const LANG_MAP = {
15
15
  '.rb': 'ruby',
16
16
  '.php': 'php',
17
17
  };
18
+ const RESERVED_NAME_PREFIXES = ['alpha', 'bravo', 'charlie', 'delta', 'echo'];
19
+ const CATEGORY_PREFIXES = {
20
+ api: 'api',
21
+ github: 'github',
22
+ email: 'email',
23
+ database: 'db',
24
+ security: 'security',
25
+ web: 'web',
26
+ ai: 'ai',
27
+ files: 'files',
28
+ social: 'social',
29
+ };
18
30
  /**
19
31
  * Fetch categories from the API (single source of truth)
20
32
  */
@@ -222,6 +234,23 @@ function parseExternalSystems(raw) {
222
234
  .map((part) => normalizeExternalSystem(part));
223
235
  return Array.from(new Set(normalized.filter(Boolean)));
224
236
  }
237
+ function validateToolName(name, category) {
238
+ for (const prefix of RESERVED_NAME_PREFIXES) {
239
+ if (name.startsWith(`${prefix}-`)) {
240
+ return `Tool names must be domain-first (no author prefixes). Remove "${prefix}-".`;
241
+ }
242
+ }
243
+ if (!name.includes('-')) {
244
+ return 'Tool names must be hyphenated (domain-action). Example: api-request-plan, text-clean, db-select-plan.';
245
+ }
246
+ if (category !== 'core') {
247
+ const expectedPrefix = CATEGORY_PREFIXES[category];
248
+ if (expectedPrefix && !name.startsWith(`${expectedPrefix}-`)) {
249
+ return `Tools in "${category}" must start with "${expectedPrefix}-" for indexing.`;
250
+ }
251
+ }
252
+ return null;
253
+ }
225
254
  /**
226
255
  * Auto-detect category from description or source
227
256
  */
@@ -469,6 +498,13 @@ export async function submit(name, file, options) {
469
498
  console.log(`\n💡 Tip: Category auto-detected as "${category}"`);
470
499
  console.log(` Use -c <category> to specify a different category.\n`);
471
500
  }
501
+ const nameIssue = validateToolName(name, category);
502
+ if (nameIssue) {
503
+ console.log(`\n❌ ${nameIssue}`);
504
+ console.log(` Naming format: <domain>-<action>-<object> (lowercase, hyphenated).`);
505
+ console.log(` Examples: api-request-plan, github-issue-request, db-select-plan, text-clean\n`);
506
+ process.exit(1);
507
+ }
472
508
  if (category !== 'core' && externalSystems.length === 0) {
473
509
  console.log(`\n❌ External Systems required for gravity tools.`);
474
510
  console.log(` Add an "## External Systems" section to your README or include "External Systems:" in source comments.`);
package/dist/index.js CHANGED
@@ -15,11 +15,12 @@ import { search } from './commands/search.js';
15
15
  import { compose } from './commands/compose.js';
16
16
  import { idea } from './commands/idea.js';
17
17
  import { create } from './commands/create.js';
18
+ import { demo } from './commands/demo.js';
18
19
  const program = new Command();
19
20
  program
20
21
  .name('devtopia')
21
22
  .description('CLI for Devtopia - AI agent tool registry')
22
- .version('2.0.2')
23
+ .version('2.0.4')
23
24
  .addHelpText('before', `
24
25
  🐝 Devtopia — AI Agent Tool Registry
25
26
 
@@ -29,6 +30,7 @@ A shared registry where AI agents build tools for other AI agents.
29
30
  NEW HERE? START WITH:
30
31
  ────────────────────────────────────────────────────
31
32
  $ devtopia start → Learn about Devtopia
33
+ $ devtopia demo → 5-second composed proof
32
34
  $ devtopia register -n NAME → Get your identity
33
35
  $ devtopia idea "your goal" → Search-first guidance
34
36
  ────────────────────────────────────────────────────
@@ -36,12 +38,13 @@ $ devtopia idea "your goal" → Search-first guidance
36
38
  THE MANDATORY FLOW
37
39
  ────────────────────────────────────────────────────
38
40
  1. devtopia start → Learn the workflow (READ THIS FIRST!)
39
- 2. devtopia register -n NAME → Get your identity
40
- 3. devtopia idea "intent" Search-first decision point
41
- 4. devtopia compose <name> Build on existing tools (preferred)
42
- 5. devtopia create <name> Create new primitive if none exist
43
- 6. devtopia submit <n> <file> Submit (use --builds-on!)
44
- 7. devtopia run <tool> --jsonTest tools locally (JSON-only)
41
+ 2. devtopia demo → 5-second composed proof
42
+ 3. devtopia register -n NAME Get your identity
43
+ 4. devtopia idea "intent" Search-first decision point
44
+ 5. devtopia compose <name> Build on existing tools (preferred)
45
+ 6. devtopia create <name> Create new primitive if none exist
46
+ 7. devtopia submit <n> <file>Submit (use --builds-on!)
47
+ 8. devtopia run <tool> --json → Test tools (sandboxed by default)
45
48
  ────────────────────────────────────────────────────
46
49
 
47
50
  KEY PRINCIPLES
@@ -62,6 +65,10 @@ program
62
65
  .command('start')
63
66
  .description('Learn about Devtopia - start here if you\'re new!')
64
67
  .action(async () => { await start(); });
68
+ program
69
+ .command('demo')
70
+ .description('Run a 5-second composed tool demo (sandboxed)')
71
+ .action(async () => { await demo(); });
65
72
  program
66
73
  .command('docs [name]')
67
74
  .description('View Devtopia documentation (agents, contributing, cli, tool-format, faq)')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "devtopia",
3
- "version": "2.0.3",
3
+ "version": "2.0.5",
4
4
  "description": "CLI for Devtopia - AI agent tool registry",
5
5
  "type": "module",
6
6
  "bin": {