@framers/agentos-template-basic-tool 1.0.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/LICENSE +21 -0
- package/README.md +146 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +60 -0
- package/dist/index.js.map +1 -0
- package/dist/tools/exampleTool.d.ts +40 -0
- package/dist/tools/exampleTool.d.ts.map +1 -0
- package/dist/tools/exampleTool.js +148 -0
- package/dist/tools/exampleTool.js.map +1 -0
- package/dist/types.d.ts +34 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +7 -0
- package/dist/types.js.map +1 -0
- package/manifest.json +43 -0
- package/package.json +52 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Frame.dev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
# Template Extension for AgentOS
|
|
2
|
+
|
|
3
|
+
A template for creating new AgentOS extensions.
|
|
4
|
+
|
|
5
|
+
## Quick Start
|
|
6
|
+
|
|
7
|
+
1. **Copy this template**:
|
|
8
|
+
```bash
|
|
9
|
+
cp -r ext-template ext-myextension
|
|
10
|
+
cd ext-myextension
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
2. **Update package.json**:
|
|
14
|
+
- Change name to `@framers/agentos-ext-{yourname}`
|
|
15
|
+
- Update description, author, keywords
|
|
16
|
+
|
|
17
|
+
3. **Update manifest.json**:
|
|
18
|
+
- Change id to `com.framers.ext.{yourname}`
|
|
19
|
+
- Update metadata
|
|
20
|
+
|
|
21
|
+
4. **Implement your tools**:
|
|
22
|
+
- Create tools in `src/tools/`
|
|
23
|
+
- Implement `ITool` interface
|
|
24
|
+
- Export from `src/index.ts`
|
|
25
|
+
|
|
26
|
+
## Development
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
# Install dependencies
|
|
30
|
+
npm install
|
|
31
|
+
|
|
32
|
+
# Build
|
|
33
|
+
npm run build
|
|
34
|
+
|
|
35
|
+
# Watch mode
|
|
36
|
+
npm run dev
|
|
37
|
+
|
|
38
|
+
# Run tests
|
|
39
|
+
npm test
|
|
40
|
+
|
|
41
|
+
# Lint
|
|
42
|
+
npm run lint
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
## Structure
|
|
46
|
+
|
|
47
|
+
```
|
|
48
|
+
ext-template/
|
|
49
|
+
├── src/
|
|
50
|
+
│ ├── index.ts # Extension pack export
|
|
51
|
+
│ ├── tools/
|
|
52
|
+
│ │ └── exampleTool.ts # Example tool implementation
|
|
53
|
+
│ └── types.ts # TypeScript definitions
|
|
54
|
+
├── test/
|
|
55
|
+
│ └── unit/
|
|
56
|
+
│ └── exampleTool.spec.ts
|
|
57
|
+
├── manifest.json # Extension metadata
|
|
58
|
+
├── package.json
|
|
59
|
+
└── README.md
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Creating a Tool
|
|
63
|
+
|
|
64
|
+
```typescript
|
|
65
|
+
import type { ITool, ToolExecutionContext, ToolExecutionResult } from '@framers/agentos';
|
|
66
|
+
|
|
67
|
+
export class MyTool implements ITool {
|
|
68
|
+
readonly id = 'com.framers.ext.myext.myTool';
|
|
69
|
+
readonly name = 'myTool';
|
|
70
|
+
readonly displayName = 'My Tool';
|
|
71
|
+
readonly description = 'What this tool does';
|
|
72
|
+
|
|
73
|
+
readonly inputSchema = {
|
|
74
|
+
type: 'object',
|
|
75
|
+
properties: {
|
|
76
|
+
// Define inputs
|
|
77
|
+
},
|
|
78
|
+
required: []
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
async execute(input: any, context: ToolExecutionContext): Promise<ToolExecutionResult> {
|
|
82
|
+
try {
|
|
83
|
+
// Your implementation
|
|
84
|
+
return { success: true, output: {} };
|
|
85
|
+
} catch (error) {
|
|
86
|
+
return { success: false, error: error.message };
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
## Configuration
|
|
93
|
+
|
|
94
|
+
Extensions can access configuration through the context:
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
async execute(input: any, context: ToolExecutionContext) {
|
|
98
|
+
const config = context.configuration?.['myext'] || {};
|
|
99
|
+
const apiKey = config.apiKey;
|
|
100
|
+
// Use configuration
|
|
101
|
+
}
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### Declaring Secrets
|
|
105
|
+
|
|
106
|
+
If your tool needs an API key, declare it on the descriptor so hosts can surface the requirement:
|
|
107
|
+
|
|
108
|
+
```ts
|
|
109
|
+
requiredSecrets: [{ id: 'openai.apiKey' }],
|
|
110
|
+
onActivate: (ctx) => {
|
|
111
|
+
exampleTool.setApiKey(ctx.getSecret?.('openai.apiKey'));
|
|
112
|
+
},
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
Secret IDs correspond to `packages/agentos/src/config/extension-secrets.json` and are also visible inside the AgentOS client UI.
|
|
116
|
+
|
|
117
|
+
## Testing
|
|
118
|
+
|
|
119
|
+
Write comprehensive tests:
|
|
120
|
+
|
|
121
|
+
```typescript
|
|
122
|
+
import { describe, it, expect } from 'vitest';
|
|
123
|
+
import { MyTool } from '../src/tools/myTool';
|
|
124
|
+
|
|
125
|
+
describe('MyTool', () => {
|
|
126
|
+
it('executes correctly', async () => {
|
|
127
|
+
const tool = new MyTool();
|
|
128
|
+
const result = await tool.execute(
|
|
129
|
+
{ /* input */ },
|
|
130
|
+
{ /* context */ } as any
|
|
131
|
+
);
|
|
132
|
+
expect(result.success).toBe(true);
|
|
133
|
+
});
|
|
134
|
+
});
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Publishing
|
|
138
|
+
|
|
139
|
+
1. Build: `npm run build`
|
|
140
|
+
2. Test: `npm test`
|
|
141
|
+
3. Version: `npm version patch|minor|major`
|
|
142
|
+
4. Publish: `npm publish --access public`
|
|
143
|
+
|
|
144
|
+
## License
|
|
145
|
+
|
|
146
|
+
MIT - See LICENSE
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Extension pack entry point
|
|
3
|
+
* @description Creates and exports the extension pack for AgentOS
|
|
4
|
+
*/
|
|
5
|
+
import type { ExtensionPack, ExtensionPackContext } from '@framers/agentos';
|
|
6
|
+
/**
|
|
7
|
+
* Creates the extension pack with all tools, guardrails, and other extensions
|
|
8
|
+
*/
|
|
9
|
+
export declare function createExtensionPack(context: ExtensionPackContext): ExtensionPack;
|
|
10
|
+
export default createExtensionPack;
|
|
11
|
+
export { ExampleTool } from './tools/exampleTool';
|
|
12
|
+
export type { ExampleToolInput, ExampleToolOutput } from './types';
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA;;;GAGG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAG5E;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,oBAAoB,GAAG,aAAa,CA2ChF;AAGD,eAAe,mBAAmB,CAAC;AAGnC,OAAO,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAClD,YAAY,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
/**
|
|
4
|
+
* @file Extension pack entry point
|
|
5
|
+
* @description Creates and exports the extension pack for AgentOS
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ExampleTool = void 0;
|
|
9
|
+
exports.createExtensionPack = createExtensionPack;
|
|
10
|
+
const exampleTool_1 = require("./tools/exampleTool");
|
|
11
|
+
/**
|
|
12
|
+
* Creates the extension pack with all tools, guardrails, and other extensions
|
|
13
|
+
*/
|
|
14
|
+
function createExtensionPack(context) {
|
|
15
|
+
const { options = {} } = context;
|
|
16
|
+
// Initialize any services or configuration
|
|
17
|
+
const config = {
|
|
18
|
+
apiKey: options.apiKey || process.env.TEMPLATE_API_KEY,
|
|
19
|
+
endpoint: options.endpoint || 'https://api.example.com',
|
|
20
|
+
...options
|
|
21
|
+
};
|
|
22
|
+
const tool = new exampleTool_1.ExampleTool(config);
|
|
23
|
+
return {
|
|
24
|
+
name: '@framers/agentos-ext-template',
|
|
25
|
+
version: '1.0.0',
|
|
26
|
+
descriptors: [
|
|
27
|
+
{
|
|
28
|
+
id: 'exampleTool',
|
|
29
|
+
kind: 'tool',
|
|
30
|
+
payload: tool,
|
|
31
|
+
priority: 10,
|
|
32
|
+
enableByDefault: true,
|
|
33
|
+
requiredSecrets: [{ id: 'openai.apiKey' }],
|
|
34
|
+
metadata: {
|
|
35
|
+
category: 'utility',
|
|
36
|
+
requiresApiKey: true,
|
|
37
|
+
documentation: 'https://github.com/framersai/agentos-extensions/tree/main/packages/ext-template'
|
|
38
|
+
},
|
|
39
|
+
source: context.source,
|
|
40
|
+
onActivate: async (ctx) => {
|
|
41
|
+
ctx.logger?.info('[Template Extension] Example tool activated');
|
|
42
|
+
const secret = ctx.getSecret?.('openai.apiKey');
|
|
43
|
+
if (secret) {
|
|
44
|
+
tool.setApiKey(secret);
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
onDeactivate: async (ctx) => {
|
|
48
|
+
ctx.logger?.info('[Template Extension] Example tool deactivated');
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
// Add more tools, guardrails, etc. here
|
|
52
|
+
]
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
// Default export for CommonJS compatibility
|
|
56
|
+
exports.default = createExtensionPack;
|
|
57
|
+
// Named exports for specific tools if needed
|
|
58
|
+
var exampleTool_2 = require("./tools/exampleTool");
|
|
59
|
+
Object.defineProperty(exports, "ExampleTool", { enumerable: true, get: function () { return exampleTool_2.ExampleTool; } });
|
|
60
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";AAAA,cAAc;AACd;;;GAGG;;;AAQH,kDA2CC;AAhDD,qDAAkD;AAElD;;GAEG;AACH,SAAgB,mBAAmB,CAAC,OAA6B;IAC/D,MAAM,EAAE,OAAO,GAAG,EAAE,EAAE,GAAG,OAAO,CAAC;IAEjC,2CAA2C;IAC3C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1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Example tool implementation
|
|
3
|
+
* @description Demonstrates how to implement the ITool interface
|
|
4
|
+
*/
|
|
5
|
+
import type { ITool, ToolExecutionContext, ToolExecutionResult, JSONSchemaObject } from '@framers/agentos';
|
|
6
|
+
import type { ExampleToolInput, ExampleToolOutput } from '../types';
|
|
7
|
+
export declare class ExampleTool implements ITool<ExampleToolInput, ExampleToolOutput> {
|
|
8
|
+
readonly id = "com.framers.ext.template.exampleTool";
|
|
9
|
+
readonly name = "exampleTool";
|
|
10
|
+
readonly displayName = "Example Tool";
|
|
11
|
+
readonly description = "An example tool that demonstrates the AgentOS tool pattern";
|
|
12
|
+
readonly version = "1.0.0";
|
|
13
|
+
private config;
|
|
14
|
+
constructor(config?: Record<string, any>);
|
|
15
|
+
setApiKey(apiKey?: string): void;
|
|
16
|
+
/**
|
|
17
|
+
* Input schema for validation
|
|
18
|
+
*/
|
|
19
|
+
readonly inputSchema: JSONSchemaObject;
|
|
20
|
+
/**
|
|
21
|
+
* Output schema for validation
|
|
22
|
+
*/
|
|
23
|
+
readonly outputSchema: JSONSchemaObject;
|
|
24
|
+
/**
|
|
25
|
+
* Required permissions and capabilities
|
|
26
|
+
*/
|
|
27
|
+
readonly permissions: {
|
|
28
|
+
requiredScopes: never[];
|
|
29
|
+
requiredCapabilities: never[];
|
|
30
|
+
};
|
|
31
|
+
/**
|
|
32
|
+
* Execute the tool
|
|
33
|
+
*/
|
|
34
|
+
execute(input: ExampleToolInput, context: ToolExecutionContext): Promise<ToolExecutionResult<ExampleToolOutput>>;
|
|
35
|
+
/**
|
|
36
|
+
* Simulate an API call for demonstration
|
|
37
|
+
*/
|
|
38
|
+
private simulateApiCall;
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=exampleTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exampleTool.d.ts","sourceRoot":"","sources":["../../src/tools/exampleTool.ts"],"names":[],"mappings":"AACA;;;GAGG;AAEH,OAAO,KAAK,EACV,KAAK,EACL,oBAAoB,EACpB,mBAAmB,EACnB,gBAAgB,EACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,KAAK,EAAE,gBAAgB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAEpE,qBAAa,WAAY,YAAW,KAAK,CAAC,gBAAgB,EAAE,iBAAiB,CAAC;IAC5E,QAAQ,CAAC,EAAE,0CAA0C;IACrD,QAAQ,CAAC,IAAI,iBAAiB;IAC9B,QAAQ,CAAC,WAAW,kBAAkB;IACtC,QAAQ,CAAC,WAAW,gEAAgE;IACpF,QAAQ,CAAC,OAAO,WAAW;IAE3B,OAAO,CAAC,MAAM,CAAsB;gBAExB,MAAM,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM;IAIrC,SAAS,CAAC,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI;IAMvC;;OAEG;IACH,QAAQ,CAAC,WAAW,EAAE,gBAAgB,CA0BpC;IAEF;;OAEG;IACH,QAAQ,CAAC,YAAY,EAAE,gBAAgB,CAgBrC;IAEF;;OAEG;IACH,QAAQ,CAAC,WAAW;;;MAGlB;IAEF;;OAEG;IACG,OAAO,CACX,KAAK,EAAE,gBAAgB,EACvB,OAAO,EAAE,oBAAoB,GAC5B,OAAO,CAAC,mBAAmB,CAAC,iBAAiB,CAAC,CAAC;IA0DlD;;OAEG;YACW,eAAe;CAS9B"}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// @ts-nocheck
|
|
3
|
+
/**
|
|
4
|
+
* @file Example tool implementation
|
|
5
|
+
* @description Demonstrates how to implement the ITool interface
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.ExampleTool = void 0;
|
|
9
|
+
class ExampleTool {
|
|
10
|
+
id = 'com.framers.ext.template.exampleTool';
|
|
11
|
+
name = 'exampleTool';
|
|
12
|
+
displayName = 'Example Tool';
|
|
13
|
+
description = 'An example tool that demonstrates the AgentOS tool pattern';
|
|
14
|
+
version = '1.0.0';
|
|
15
|
+
config;
|
|
16
|
+
constructor(config = {}) {
|
|
17
|
+
this.config = config;
|
|
18
|
+
}
|
|
19
|
+
setApiKey(apiKey) {
|
|
20
|
+
if (apiKey) {
|
|
21
|
+
this.config.apiKey = apiKey;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Input schema for validation
|
|
26
|
+
*/
|
|
27
|
+
inputSchema = {
|
|
28
|
+
type: 'object',
|
|
29
|
+
properties: {
|
|
30
|
+
message: {
|
|
31
|
+
type: 'string',
|
|
32
|
+
description: 'A message to process'
|
|
33
|
+
},
|
|
34
|
+
options: {
|
|
35
|
+
type: 'object',
|
|
36
|
+
properties: {
|
|
37
|
+
uppercase: {
|
|
38
|
+
type: 'boolean',
|
|
39
|
+
description: 'Convert message to uppercase',
|
|
40
|
+
default: false
|
|
41
|
+
},
|
|
42
|
+
repeat: {
|
|
43
|
+
type: 'integer',
|
|
44
|
+
description: 'Number of times to repeat the message',
|
|
45
|
+
minimum: 1,
|
|
46
|
+
maximum: 10,
|
|
47
|
+
default: 1
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
required: ['message']
|
|
53
|
+
};
|
|
54
|
+
/**
|
|
55
|
+
* Output schema for validation
|
|
56
|
+
*/
|
|
57
|
+
outputSchema = {
|
|
58
|
+
type: 'object',
|
|
59
|
+
properties: {
|
|
60
|
+
result: {
|
|
61
|
+
type: 'string',
|
|
62
|
+
description: 'The processed message'
|
|
63
|
+
},
|
|
64
|
+
metadata: {
|
|
65
|
+
type: 'object',
|
|
66
|
+
properties: {
|
|
67
|
+
originalLength: { type: 'integer' },
|
|
68
|
+
processedLength: { type: 'integer' },
|
|
69
|
+
processingTime: { type: 'number' }
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
};
|
|
74
|
+
/**
|
|
75
|
+
* Required permissions and capabilities
|
|
76
|
+
*/
|
|
77
|
+
permissions = {
|
|
78
|
+
requiredScopes: [],
|
|
79
|
+
requiredCapabilities: []
|
|
80
|
+
};
|
|
81
|
+
/**
|
|
82
|
+
* Execute the tool
|
|
83
|
+
*/
|
|
84
|
+
async execute(input, context) {
|
|
85
|
+
const startTime = Date.now();
|
|
86
|
+
try {
|
|
87
|
+
// Validate configuration
|
|
88
|
+
if (this.config.requiresApiKey && !this.config.apiKey) {
|
|
89
|
+
return {
|
|
90
|
+
success: false,
|
|
91
|
+
error: 'API key is required but not configured',
|
|
92
|
+
details: {
|
|
93
|
+
code: 'MISSING_API_KEY',
|
|
94
|
+
help: 'Set the API key in extension configuration or environment variables'
|
|
95
|
+
}
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
// Process the input
|
|
99
|
+
let result = input.message;
|
|
100
|
+
// Apply options
|
|
101
|
+
if (input.options?.uppercase) {
|
|
102
|
+
result = result.toUpperCase();
|
|
103
|
+
}
|
|
104
|
+
if (input.options?.repeat && input.options.repeat > 1) {
|
|
105
|
+
result = Array(input.options.repeat).fill(result).join(' ');
|
|
106
|
+
}
|
|
107
|
+
// Simulate async operation
|
|
108
|
+
await this.simulateApiCall();
|
|
109
|
+
const processingTime = Date.now() - startTime;
|
|
110
|
+
return {
|
|
111
|
+
success: true,
|
|
112
|
+
output: {
|
|
113
|
+
result,
|
|
114
|
+
metadata: {
|
|
115
|
+
originalLength: input.message.length,
|
|
116
|
+
processedLength: result.length,
|
|
117
|
+
processingTime
|
|
118
|
+
}
|
|
119
|
+
},
|
|
120
|
+
contentType: 'application/json'
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
return {
|
|
125
|
+
success: false,
|
|
126
|
+
error: error instanceof Error ? error.message : 'Unknown error occurred',
|
|
127
|
+
details: {
|
|
128
|
+
timestamp: new Date().toISOString(),
|
|
129
|
+
input,
|
|
130
|
+
stack: error instanceof Error ? error.stack : undefined
|
|
131
|
+
}
|
|
132
|
+
};
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Simulate an API call for demonstration
|
|
137
|
+
*/
|
|
138
|
+
async simulateApiCall() {
|
|
139
|
+
// Simulate network delay
|
|
140
|
+
await new Promise(resolve => setTimeout(resolve, 100));
|
|
141
|
+
// Could make actual API calls here:
|
|
142
|
+
// const response = await fetch(this.config.endpoint, {
|
|
143
|
+
// headers: { 'Authorization': `Bearer ${this.config.apiKey}` }
|
|
144
|
+
// });
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
exports.ExampleTool = ExampleTool;
|
|
148
|
+
//# sourceMappingURL=exampleTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exampleTool.js","sourceRoot":"","sources":["../../src/tools/exampleTool.ts"],"names":[],"mappings":";AAAA,cAAc;AACd;;;GAGG;;;AAUH,MAAa,WAAW;IACb,EAAE,GAAG,sCAAsC,CAAC;IAC5C,IAAI,GAAG,aAAa,CAAC;IACrB,WAAW,GAAG,cAAc,CAAC;IAC7B,WAAW,GAAG,4DAA4D,CAAC;IAC3E,OAAO,GAAG,OAAO,CAAC;IAEnB,MAAM,CAAsB;IAEpC,YAAY,SAA8B,EAAE;QAC1C,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;IAEM,SAAS,CAAC,MAAe;QAC9B,IAAI,MAAM,EAAE,CAAC;YACX,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC;QAC9B,CAAC;IACH,CAAC;IAED;;OAEG;IACM,WAAW,GAAqB;QACvC,IAAI,EAAE,QAAQ;QACd,UAAU,EAAE;YACV,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,sBAAsB;aACpC;YACD,OAAO,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,UAAU,EAAE;oBACV,SAA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AI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,GAAG,CAAC,CAAC,CAAC;QAEvD,oCAAoC;QACpC,uDAAuD;QACvD,iEAAiE;QACjE,MAAM;IACR,CAAC;CACF;AA3JD,kCA2JC"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Type definitions for the template extension
|
|
3
|
+
*/
|
|
4
|
+
/**
|
|
5
|
+
* Input type for the example tool
|
|
6
|
+
*/
|
|
7
|
+
export interface ExampleToolInput {
|
|
8
|
+
message: string;
|
|
9
|
+
options?: {
|
|
10
|
+
uppercase?: boolean;
|
|
11
|
+
repeat?: number;
|
|
12
|
+
};
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Output type for the example tool
|
|
16
|
+
*/
|
|
17
|
+
export interface ExampleToolOutput {
|
|
18
|
+
result: string;
|
|
19
|
+
metadata: {
|
|
20
|
+
originalLength: number;
|
|
21
|
+
processedLength: number;
|
|
22
|
+
processingTime: number;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Configuration options for the extension
|
|
27
|
+
*/
|
|
28
|
+
export interface ExtensionConfig {
|
|
29
|
+
apiKey?: string;
|
|
30
|
+
endpoint?: string;
|
|
31
|
+
requiresApiKey?: boolean;
|
|
32
|
+
debug?: boolean;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AACA;;GAEG;AAEH;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,CAAC,EAAE;QACR,SAAS,CAAC,EAAE,OAAO,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE;QACR,cAAc,EAAE,MAAM,CAAC;QACvB,eAAe,EAAE,MAAM,CAAC;QACxB,cAAc,EAAE,MAAM,CAAC;KACxB,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,KAAK,CAAC,EAAE,OAAO,CAAC;CACjB"}
|
package/dist/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":";AAAA,cAAc;AACd;;GAEG"}
|
package/manifest.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://agentos.sh/schemas/extension-manifest-v1.json",
|
|
3
|
+
"id": "com.framers.ext.template",
|
|
4
|
+
"name": "Template Extension",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"description": "A template for creating new AgentOS extensions",
|
|
7
|
+
"author": {
|
|
8
|
+
"name": "Your Name",
|
|
9
|
+
"email": "your.email@example.com",
|
|
10
|
+
"url": "https://github.com/yourusername"
|
|
11
|
+
},
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"keywords": ["template", "example"],
|
|
14
|
+
"agentosVersion": "^2.0.0",
|
|
15
|
+
"categories": ["utility"],
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/framersai/agentos-extensions"
|
|
19
|
+
},
|
|
20
|
+
"extensions": [
|
|
21
|
+
{
|
|
22
|
+
"kind": "tool",
|
|
23
|
+
"id": "exampleTool",
|
|
24
|
+
"displayName": "Example Tool",
|
|
25
|
+
"description": "An example tool implementation",
|
|
26
|
+
"entry": "./dist/tools/exampleTool.js"
|
|
27
|
+
}
|
|
28
|
+
],
|
|
29
|
+
"configuration": {
|
|
30
|
+
"properties": {
|
|
31
|
+
"template.apiKey": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "API key for external service",
|
|
34
|
+
"secret": true
|
|
35
|
+
},
|
|
36
|
+
"template.endpoint": {
|
|
37
|
+
"type": "string",
|
|
38
|
+
"default": "https://api.example.com",
|
|
39
|
+
"description": "API endpoint URL"
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@framers/agentos-template-basic-tool",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Template for creating AgentOS extensions",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"keywords": [
|
|
8
|
+
"agentos",
|
|
9
|
+
"extension",
|
|
10
|
+
"template"
|
|
11
|
+
],
|
|
12
|
+
"author": {
|
|
13
|
+
"name": "Framers AI",
|
|
14
|
+
"email": "team@frame.dev",
|
|
15
|
+
"url": "https://frame.dev"
|
|
16
|
+
},
|
|
17
|
+
"contributors": [
|
|
18
|
+
{
|
|
19
|
+
"name": "Johnny Dunn",
|
|
20
|
+
"email": "johnnyfived@protonmail.com",
|
|
21
|
+
"url": "https://github.com/jddunn"
|
|
22
|
+
}
|
|
23
|
+
],
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"repository": {
|
|
26
|
+
"type": "git",
|
|
27
|
+
"url": "https://github.com/framersai/agentos-extensions",
|
|
28
|
+
"directory": "packages/ext-template"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"manifest.json",
|
|
33
|
+
"README.md"
|
|
34
|
+
],
|
|
35
|
+
"peerDependencies": {
|
|
36
|
+
"@framers/agentos": "^0.5.2"
|
|
37
|
+
},
|
|
38
|
+
"devDependencies": {
|
|
39
|
+
"@framers/agentos": "^0.5.2",
|
|
40
|
+
"@types/node": "^20.0.0",
|
|
41
|
+
"typescript": "^5.0.0",
|
|
42
|
+
"vitest": "^1.0.0"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsc",
|
|
46
|
+
"dev": "tsc --watch",
|
|
47
|
+
"test": "vitest",
|
|
48
|
+
"test:coverage": "vitest --coverage",
|
|
49
|
+
"lint": "eslint src --ext .ts",
|
|
50
|
+
"clean": "rm -rf dist"
|
|
51
|
+
}
|
|
52
|
+
}
|