@a5c-ai/tula 5.0.1-staging.3edc9d7b8d6f
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 +34 -0
- package/dist/cli/amuxEventsFormatter.d.ts +26 -0
- package/dist/cli/amuxEventsFormatter.d.ts.map +1 -0
- package/dist/cli/amuxEventsFormatter.js +86 -0
- package/dist/cli/args/argFlags.d.ts +6 -0
- package/dist/cli/args/argFlags.d.ts.map +1 -0
- package/dist/cli/args/argFlags.js +72 -0
- package/dist/cli/args/argPositionals.d.ts +3 -0
- package/dist/cli/args/argPositionals.d.ts.map +1 -0
- package/dist/cli/args/argPositionals.js +18 -0
- package/dist/cli/args/index.d.ts +4 -0
- package/dist/cli/args/index.d.ts.map +1 -0
- package/dist/cli/args/index.js +75 -0
- package/dist/cli/args/types.d.ts +13 -0
- package/dist/cli/args/types.d.ts.map +1 -0
- package/dist/cli/args/types.js +2 -0
- package/dist/cli/commands/daemon.d.ts +31 -0
- package/dist/cli/commands/daemon.d.ts.map +1 -0
- package/dist/cli/commands/daemon.js +156 -0
- package/dist/cli/commands/harness/createRun.d.ts +3 -0
- package/dist/cli/commands/harness/createRun.d.ts.map +1 -0
- package/dist/cli/commands/harness/createRun.js +8 -0
- package/dist/cli/commands/harness/resumeRun.d.ts +20 -0
- package/dist/cli/commands/harness/resumeRun.d.ts.map +1 -0
- package/dist/cli/commands/harness/resumeRun.js +341 -0
- package/dist/cli/commands/jsonlInteractive.d.ts +35 -0
- package/dist/cli/commands/jsonlInteractive.d.ts.map +1 -0
- package/dist/cli/commands/jsonlInteractive.js +302 -0
- package/dist/cli/commands/mcpServe.d.ts +18 -0
- package/dist/cli/commands/mcpServe.d.ts.map +1 -0
- package/dist/cli/commands/mcpServe.js +59 -0
- package/dist/cli/commands/session/history.d.ts +14 -0
- package/dist/cli/commands/session/history.d.ts.map +1 -0
- package/dist/cli/commands/session/history.js +100 -0
- package/dist/cli/commands/tui.d.ts +23 -0
- package/dist/cli/commands/tui.d.ts.map +1 -0
- package/dist/cli/commands/tui.js +183 -0
- package/dist/cli/dispatch.d.ts +4 -0
- package/dist/cli/dispatch.d.ts.map +1 -0
- package/dist/cli/dispatch.js +348 -0
- package/dist/cli/main.d.ts +7 -0
- package/dist/cli/main.d.ts.map +1 -0
- package/dist/cli/main.js +41 -0
- package/dist/cli/program.d.ts +7 -0
- package/dist/cli/program.d.ts.map +1 -0
- package/dist/cli/program.js +8 -0
- package/dist/cli/ui.d.ts +9 -0
- package/dist/cli/ui.d.ts.map +1 -0
- package/dist/cli/ui.js +125 -0
- package/dist/index.d.ts +18 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +59 -0
- package/dist/prompts/commandTemplates.d.ts +3 -0
- package/dist/prompts/commandTemplates.d.ts.map +1 -0
- package/dist/prompts/commandTemplates.js +238 -0
- package/package.json +76 -0
|
@@ -0,0 +1,238 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.renderCommandTemplate = renderCommandTemplate;
|
|
4
|
+
const babysitter_sdk_1 = require("@a5c-ai/babysitter-sdk");
|
|
5
|
+
const COMMAND_TEMPLATE_CONTEXT = {
|
|
6
|
+
harness: "harness-command-template",
|
|
7
|
+
harnessLabel: "Harness Command Template",
|
|
8
|
+
interactive: undefined,
|
|
9
|
+
capabilities: [],
|
|
10
|
+
platform: process.platform,
|
|
11
|
+
pluginRootVar: "",
|
|
12
|
+
loopControlTerm: "",
|
|
13
|
+
sessionBindingFlags: "",
|
|
14
|
+
hookDriven: false,
|
|
15
|
+
interactiveToolName: "",
|
|
16
|
+
sessionEnvVars: "",
|
|
17
|
+
resumeFlags: "",
|
|
18
|
+
sdkVersionExpr: "",
|
|
19
|
+
hasIntentFidelityChecks: false,
|
|
20
|
+
hasNonNegotiables: false,
|
|
21
|
+
cliSetupSnippet: "",
|
|
22
|
+
iterateFlags: "",
|
|
23
|
+
};
|
|
24
|
+
const ANYCLI_TEMPLATE = `[ANYCLI MODE] Dynamic service integration agent for any external service
|
|
25
|
+
|
|
26
|
+
Target service: {{serviceName}}
|
|
27
|
+
Scope: {{scope}}
|
|
28
|
+
{{#mcpMode}}MCP mode: enabled (transport: {{transport}}){{/mcpMode}}
|
|
29
|
+
{{^mcpMode}}Mode: ad-hoc execution{{/mcpMode}}
|
|
30
|
+
{{#authFile}}Auth file: {{authFile}}{{/authFile}}
|
|
31
|
+
{{#userPrompt}}User request: {{userPrompt}}{{/userPrompt}}
|
|
32
|
+
|
|
33
|
+
You are a service integration agent. You handle EVERYTHING dynamically: researching the service, figuring out authentication, writing code, and generating MCP servers. There are no pre-built templates or hardcoded patterns -- you discover and create everything at runtime based on what you learn about the service.
|
|
34
|
+
|
|
35
|
+
---
|
|
36
|
+
|
|
37
|
+
## Phase 1: Service Discovery
|
|
38
|
+
|
|
39
|
+
**Goal:** Learn everything about **{{serviceName}}** and build a service definition.
|
|
40
|
+
|
|
41
|
+
### 1a. Check Cache
|
|
42
|
+
|
|
43
|
+
Check \`~/.a5c/anycli/cache/{{serviceName}}/cache.json\` for an existing cache entry.
|
|
44
|
+
|
|
45
|
+
If found, inspect \`definition\`, \`modules\`, and \`metadata.createdAt\`. You decide whether the cache is fresh enough to use. If the definition covers the requested scope (\`{{scope}}\`), skip to Phase 3 or 4.
|
|
46
|
+
|
|
47
|
+
### 1b. Research the Service
|
|
48
|
+
|
|
49
|
+
If no usable cache exists, research **{{serviceName}}** thoroughly:
|
|
50
|
+
|
|
51
|
+
1. **Web search** for official API documentation, OpenAPI/Swagger specs, developer guides.
|
|
52
|
+
2. **Identify**: base URL(s), API versioning scheme, authentication methods (specific to THIS service -- not generic patterns), rate limits, pagination style, error response format.
|
|
53
|
+
3. **Check** for existing CLI tools, SDKs (npm/pip/etc.), or MCP servers that already integrate with this service.
|
|
54
|
+
4. **Filter by scope**: \`{{scope}}\` -- if \`*\`, cover all major endpoint groups. If comma-separated, focus on those specific areas.
|
|
55
|
+
|
|
56
|
+
### 1c. Build the Definition
|
|
57
|
+
|
|
58
|
+
Construct a service definition object with whatever structure makes sense for **{{serviceName}}**. There is no rigid schema -- include the fields that are relevant:
|
|
59
|
+
|
|
60
|
+
- \`name\`, \`apiBaseUrl\`, \`displayName\`, \`description\`
|
|
61
|
+
- Authentication details specific to this service
|
|
62
|
+
- Endpoint groups filtered by scope
|
|
63
|
+
- Any service-specific metadata (rate limits, pagination, versioning, etc.)
|
|
64
|
+
|
|
65
|
+
---
|
|
66
|
+
|
|
67
|
+
## Phase 2: Auth Resolution
|
|
68
|
+
|
|
69
|
+
**Goal:** Figure out what credentials **{{serviceName}}** needs and find them.
|
|
70
|
+
|
|
71
|
+
This is entirely service-specific. Do NOT use generic patterns like \`SERVICE_API_KEY\`. Instead:
|
|
72
|
+
|
|
73
|
+
1. **Read the service docs** to understand what auth method(s) it supports (API keys, OAuth2, bearer tokens, basic auth, etc.) and what the credentials look like.
|
|
74
|
+
{{#authFile}}
|
|
75
|
+
2. **Check the auth file** at \`{{authFile}}\` for credentials. Parse it as \`.env\` or JSON format.
|
|
76
|
+
{{/authFile}}
|
|
77
|
+
{{^authFile}}
|
|
78
|
+
2. **No auth file provided**, skip to next step.
|
|
79
|
+
{{/authFile}}
|
|
80
|
+
3. **Check environment variables** using the naming conventions that are standard for THIS specific service. For example: \`GITHUB_TOKEN\` for GitHub, \`STRIPE_API_KEY\` for Stripe, \`OPENAI_API_KEY\` for OpenAI -- whatever the service's own docs and ecosystem use.
|
|
81
|
+
4. **Check workspace \`.env\`** file for the same service-specific variable names.
|
|
82
|
+
5. **If credentials are missing**, report exactly what is needed, where to get it (with links to the service's credential/API key page if known), and what env var name to use.
|
|
83
|
+
|
|
84
|
+
**Security:** Never log or hardcode credentials. Generated code must read credentials from environment variables at runtime.
|
|
85
|
+
|
|
86
|
+
---
|
|
87
|
+
|
|
88
|
+
## Phase 3: Code Generation
|
|
89
|
+
|
|
90
|
+
**Goal:** Write utility modules (\`.mjs\` files) based on what you learned about **{{serviceName}}**.
|
|
91
|
+
|
|
92
|
+
You decide the module structure, function signatures, and types based on the service's actual API. General guidelines:
|
|
93
|
+
|
|
94
|
+
- **HTTP client**: Use \`fetch()\` only -- zero external dependencies. Include auth headers, retries on 429/5xx, and the service's pagination pattern.
|
|
95
|
+
- **Scope modules**: One file per scope group with async functions for each endpoint. Full JSDoc.
|
|
96
|
+
- **Barrel export**: An \`index.mjs\` re-exporting everything.
|
|
97
|
+
- **No hardcoded credentials**: Read from env vars at runtime.
|
|
98
|
+
|
|
99
|
+
Write all modules to \`~/.a5c/anycli/cache/{{serviceName}}/modules/\`.
|
|
100
|
+
|
|
101
|
+
---
|
|
102
|
+
|
|
103
|
+
{{#mcpMode}}
|
|
104
|
+
## Phase 4: MCP Server Generation
|
|
105
|
+
|
|
106
|
+
**Goal:** Write and start a complete MCP server for **{{serviceName}}**.
|
|
107
|
+
|
|
108
|
+
Write a self-contained \`mcp-server.mjs\` file from scratch using \`@modelcontextprotocol/sdk\` patterns:
|
|
109
|
+
|
|
110
|
+
- Import \`McpServer\` from \`@modelcontextprotocol/sdk/server/mcp.js\`
|
|
111
|
+
- Import the appropriate transport for \`{{transport}}\`:
|
|
112
|
+
- \`stdio\`: \`StdioServerTransport\` from \`.../server/stdio.js\`
|
|
113
|
+
- \`http-sse\`: \`SSEServerTransport\` from \`.../server/sse.js\`
|
|
114
|
+
- Register MCP tools based on the scope modules you generated
|
|
115
|
+
- Each tool: descriptive name (\`{{serviceName}}_<action>\`), JSON Schema input, handler that calls the scope module functions
|
|
116
|
+
- Graceful shutdown on SIGINT/SIGTERM
|
|
117
|
+
|
|
118
|
+
Save to \`~/.a5c/anycli/cache/{{serviceName}}/mcp-server.mjs\` and start it.
|
|
119
|
+
|
|
120
|
+
Output MCP client config for the user:
|
|
121
|
+
\`\`\`json
|
|
122
|
+
{ "name": "{{serviceName}}-anycli", "transport": "{{transport}}",
|
|
123
|
+
"command": "node", "args": ["~/.a5c/anycli/cache/{{serviceName}}/mcp-server.mjs"] }
|
|
124
|
+
\`\`\`
|
|
125
|
+
{{/mcpMode}}
|
|
126
|
+
|
|
127
|
+
{{^mcpMode}}
|
|
128
|
+
## Phase 4: Ad-hoc Execution
|
|
129
|
+
|
|
130
|
+
**Goal:** Fulfill the user's request using the generated modules.
|
|
131
|
+
|
|
132
|
+
{{#userPrompt}}
|
|
133
|
+
### Execute request:
|
|
134
|
+
> {{userPrompt}}
|
|
135
|
+
|
|
136
|
+
1. Determine which API calls are needed.
|
|
137
|
+
2. Import the generated modules from \`~/.a5c/anycli/cache/{{serviceName}}/modules/\`.
|
|
138
|
+
3. Execute operations in logical order, chaining multi-step calls as needed.
|
|
139
|
+
4. Present results clearly: tables for lists, formatted JSON for objects, summaries for aggregations.
|
|
140
|
+
{{/userPrompt}}
|
|
141
|
+
|
|
142
|
+
{{^userPrompt}}
|
|
143
|
+
### Interactive discovery:
|
|
144
|
+
No specific request provided. List the generated modules and their exported functions with descriptions and parameters. Suggest common use cases for **{{serviceName}}** and ask the user what they want to do.
|
|
145
|
+
{{/userPrompt}}
|
|
146
|
+
{{/mcpMode}}
|
|
147
|
+
|
|
148
|
+
---
|
|
149
|
+
|
|
150
|
+
## Phase 5: Caching
|
|
151
|
+
|
|
152
|
+
**Goal:** Save everything to \`~/.a5c/anycli/cache/{{serviceName}}/cache.json\` for reuse.
|
|
153
|
+
|
|
154
|
+
Write a single cache entry with this structure:
|
|
155
|
+
\`\`\`json
|
|
156
|
+
{
|
|
157
|
+
"service": "{{serviceName}}",
|
|
158
|
+
"definition": { "...your service definition from Phase 1..." },
|
|
159
|
+
"modules": { "filename.mjs": "...file content..." },
|
|
160
|
+
"metadata": {
|
|
161
|
+
"createdAt": "<ISO timestamp>",
|
|
162
|
+
"sdkVersion": "<version>",
|
|
163
|
+
"definitionHash": "<hash of the definition>"
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
\`\`\`
|
|
167
|
+
|
|
168
|
+
The harness package provides \`readServiceCache\`, \`writeServiceCache\`, \`invalidateServiceCache\`, and \`listCachedServices\` functions in \`@a5c-ai/agent-platform\` (anycli module) for this purpose.
|
|
169
|
+
|
|
170
|
+
---
|
|
171
|
+
|
|
172
|
+
## Phase 6: Verification
|
|
173
|
+
|
|
174
|
+
1. **Syntax check**: \`node --check\` on each generated \`.mjs\` file.
|
|
175
|
+
2. **Import check**: Dynamic import of \`modules/index.mjs\` to verify exports.
|
|
176
|
+
3. **Smoke test**: If auth is available, make one lightweight API call (health endpoint or list with limit=1).
|
|
177
|
+
{{#mcpMode}}
|
|
178
|
+
4. **MCP validation**: Verify the server module loads and tool count matches expectations.
|
|
179
|
+
{{/mcpMode}}
|
|
180
|
+
|
|
181
|
+
---
|
|
182
|
+
|
|
183
|
+
## Error Handling
|
|
184
|
+
|
|
185
|
+
- **Unknown service**: Report, suggest alternative names or provide a base URL. Stop.
|
|
186
|
+
- **Missing credentials**: Report what was tried, provide setup instructions with the correct env var names for this service. Stop.
|
|
187
|
+
- **Rate limiting**: Wait if reset < 60s, otherwise report partial results.
|
|
188
|
+
- **Network errors**: Report endpoint URL and error. Suggest checking connectivity.
|
|
189
|
+
- **Security invariant**: Never include credentials in output, errors, logs, or generated comments.
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
## Output Format
|
|
194
|
+
|
|
195
|
+
\`\`\`
|
|
196
|
+
==============================================
|
|
197
|
+
ANYCLI SERVICE INTEGRATION REPORT
|
|
198
|
+
Service: {{serviceName}} Scope: {{scope}}
|
|
199
|
+
==============================================
|
|
200
|
+
|
|
201
|
+
OVERALL STATUS: <READY | PARTIAL | FAILED>
|
|
202
|
+
|
|
203
|
+
| # | Phase | Status |
|
|
204
|
+
|----|--------------------|--------|
|
|
205
|
+
| 1 | Service Discovery | <s> |
|
|
206
|
+
| 2 | Auth Resolution | <s> |
|
|
207
|
+
| 3 | Code Generation | <s> |
|
|
208
|
+
| 4 | Execution | <s> |
|
|
209
|
+
| 5 | Caching | <s> |
|
|
210
|
+
| 6 | Verification | <s> |
|
|
211
|
+
|
|
212
|
+
Cache: ~/.a5c/anycli/cache/{{serviceName}}/
|
|
213
|
+
Modules: <list> Endpoints: <count> Auth: <method> (<source>)
|
|
214
|
+
{{#mcpMode}}
|
|
215
|
+
MCP server: ~/.a5c/anycli/cache/{{serviceName}}/mcp-server.mjs
|
|
216
|
+
Transport: {{transport}}
|
|
217
|
+
{{/mcpMode}}
|
|
218
|
+
\`\`\`
|
|
219
|
+
|
|
220
|
+
**Status:** READY = all phases passed. PARTIAL = warnings but no failures. FAILED = any phase failed.
|
|
221
|
+
{{#mcpMode}}
|
|
222
|
+
Include MCP connection instructions for the user's harness.
|
|
223
|
+
{{/mcpMode}}
|
|
224
|
+
{{^mcpMode}}
|
|
225
|
+
{{#userPrompt}}
|
|
226
|
+
Include execution results prominently before the phase summary.
|
|
227
|
+
{{/userPrompt}}
|
|
228
|
+
{{/mcpMode}}
|
|
229
|
+
`;
|
|
230
|
+
function renderAnycliTemplate(extras) {
|
|
231
|
+
return (0, babysitter_sdk_1.renderTemplateString)(ANYCLI_TEMPLATE, COMMAND_TEMPLATE_CONTEXT, extras);
|
|
232
|
+
}
|
|
233
|
+
function renderCommandTemplate(templateName, extras) {
|
|
234
|
+
if (templateName === "anycli") {
|
|
235
|
+
return renderAnycliTemplate(extras);
|
|
236
|
+
}
|
|
237
|
+
return (0, babysitter_sdk_1.renderCommandTemplate)(templateName, extras);
|
|
238
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@a5c-ai/tula",
|
|
3
|
+
"version": "5.0.1-staging.3edc9d7b8d6f",
|
|
4
|
+
"description": "Tula — unified agent product integrating core, runtime, platform, and TUI",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"type": "commonjs",
|
|
7
|
+
"main": "dist/index.js",
|
|
8
|
+
"types": "dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"require": "./dist/index.js",
|
|
13
|
+
"default": "./dist/index.js"
|
|
14
|
+
},
|
|
15
|
+
"./cli": {
|
|
16
|
+
"types": "./dist/cli/main.d.ts",
|
|
17
|
+
"require": "./dist/cli/main.js",
|
|
18
|
+
"default": "./dist/cli/main.js"
|
|
19
|
+
},
|
|
20
|
+
"./package.json": "./package.json"
|
|
21
|
+
},
|
|
22
|
+
"bin": {
|
|
23
|
+
"tula": "./dist/cli/main.js"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist/",
|
|
27
|
+
"README.md"
|
|
28
|
+
],
|
|
29
|
+
"publishConfig": {
|
|
30
|
+
"access": "public"
|
|
31
|
+
},
|
|
32
|
+
"scripts": {
|
|
33
|
+
"build": "npm run build:runtime --prefix ../.. && tsc --build tsconfig.json",
|
|
34
|
+
"clean": "rimraf dist tsconfig.tsbuildinfo",
|
|
35
|
+
"test": "vitest run --config vitest.config.ts"
|
|
36
|
+
},
|
|
37
|
+
"dependencies": {
|
|
38
|
+
"@a5c-ai/tula-core": "5.0.1-staging.3edc9d7b8d6f",
|
|
39
|
+
"@a5c-ai/agent-runtime": "5.0.1-staging.3edc9d7b8d6f",
|
|
40
|
+
"@a5c-ai/agent-platform": "5.0.1-staging.3edc9d7b8d6f",
|
|
41
|
+
"@a5c-ai/agent-mux": "5.0.1-staging.3edc9d7b8d6f",
|
|
42
|
+
"@a5c-ai/babysitter-sdk": "5.0.1-staging.3edc9d7b8d6f",
|
|
43
|
+
"@modelcontextprotocol/sdk": "^1.12.1",
|
|
44
|
+
"@sinclair/typebox": "^0.34.48"
|
|
45
|
+
},
|
|
46
|
+
"devDependencies": {
|
|
47
|
+
"@types/node": "^20.11.30",
|
|
48
|
+
"rimraf": "^6.1.3",
|
|
49
|
+
"typescript": "^5.4.2",
|
|
50
|
+
"vitest": "^4.0.18"
|
|
51
|
+
},
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "git+https://github.com/a5c-ai/babysitter.git",
|
|
55
|
+
"directory": "packages/tula"
|
|
56
|
+
},
|
|
57
|
+
"homepage": "https://github.com/a5c-ai/babysitter/tree/main/packages/tula#readme",
|
|
58
|
+
"bugs": {
|
|
59
|
+
"url": "https://github.com/a5c-ai/babysitter/issues"
|
|
60
|
+
},
|
|
61
|
+
"keywords": [
|
|
62
|
+
"babysitter",
|
|
63
|
+
"tula",
|
|
64
|
+
"agent",
|
|
65
|
+
"orchestration",
|
|
66
|
+
"unified"
|
|
67
|
+
],
|
|
68
|
+
"atlas": {
|
|
69
|
+
"layers": [
|
|
70
|
+
"L4",
|
|
71
|
+
"L5",
|
|
72
|
+
"L6"
|
|
73
|
+
],
|
|
74
|
+
"muxes": []
|
|
75
|
+
}
|
|
76
|
+
}
|