Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions eslint.config.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@ const config = createConfig([
files: ['**/*.ts', '**/*.tsx', '**/*.mts', '**/*.cts', '**/*.d.ts'],
extends: [metamaskTypescriptConfig],
rules: {
// Don't require JSDoc for type declarations.
'jsdoc/require-jsdoc': [
'error',
{
require: {
FunctionDeclaration: true,
MethodDefinition: true,
ClassDeclaration: true,
},
contexts: [],
},
],

// Require explicit function return types.
'@typescript-eslint/explicit-function-return-type': [
'error',
{
Expand Down Expand Up @@ -141,6 +155,7 @@ const config = createConfig([
files: ['**/test/**/*', '**/*.test.ts', '**/*.test.tsx'],
rules: {
'@typescript-eslint/explicit-function-return-type': 'off',
'jsdoc/require-jsdoc': 'off',
},
},

Expand Down Expand Up @@ -260,6 +275,20 @@ const config = createConfig([
'import-x/no-unresolved': 'off',
},
},

{
files: [
'**/vite.config.*',
'**/vite-plugins/**/*',
'**/vats/**/*.js',
'**/vitest.config.ts',
'**/vitest.config.e2e.ts',
'yarn.config.cjs',
],
rules: {
'jsdoc/require-jsdoc': 'off',
},
},
]);

export default config;
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,12 +55,12 @@
"@arethetypeswrong/cli": "^0.17.4",
"@lavamoat/allow-scripts": "^3.3.2",
"@lavamoat/preinstall-always-fail": "^2.1.0",
"@metamask/auto-changelog": "^5.0.1",
"@metamask/create-release-branch": "^4.1.2",
"@metamask/eslint-config": "^14.0.0",
"@metamask/eslint-config-nodejs": "^14.0.0",
"@metamask/eslint-config-typescript": "^14.0.0",
"@metamask/eslint-config-vitest": "^1.0.0",
"@metamask/auto-changelog": "^5.3.0",
"@metamask/create-release-branch": "^4.1.3",
"@metamask/eslint-config": "^15.0.0",
"@metamask/eslint-config-nodejs": "^15.0.0",
"@metamask/eslint-config-typescript": "^15.0.0",
"@metamask/eslint-config-vitest": "^15.0.0",
"@ocap/cli": "workspace:^",
"@ts-bridge/cli": "^0.6.3",
"@ts-bridge/shims": "^0.1.1",
Expand Down
12 changes: 6 additions & 6 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,8 @@
"@metamask/kernel-shims": "workspace:^",
"@metamask/kernel-utils": "workspace:^",
"@metamask/logger": "workspace:^",
"@metamask/snaps-utils": "^11.6.1",
"@metamask/utils": "^11.4.2",
"@metamask/snaps-utils": "^11.7.1",
"@metamask/utils": "^11.9.0",
"@types/node": "^22.13.1",
"chokidar": "^4.0.1",
"glob": "^11.0.0",
Expand All @@ -60,10 +60,10 @@
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.4",
"@metamask/auto-changelog": "^5.0.1",
"@metamask/eslint-config": "^14.0.0",
"@metamask/eslint-config-nodejs": "^14.0.0",
"@metamask/eslint-config-typescript": "^14.0.0",
"@metamask/auto-changelog": "^5.3.0",
"@metamask/eslint-config": "^15.0.0",
"@metamask/eslint-config-nodejs": "^15.0.0",
"@metamask/eslint-config-typescript": "^15.0.0",
"@ocap/repo-tools": "workspace:^",
"@ts-bridge/cli": "^0.6.3",
"@ts-bridge/shims": "^0.1.1",
Expand Down
10 changes: 5 additions & 5 deletions packages/create-package/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,11 @@
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.4",
"@metamask/auto-changelog": "^5.0.1",
"@metamask/eslint-config": "^14.0.0",
"@metamask/eslint-config-nodejs": "^14.0.0",
"@metamask/eslint-config-typescript": "^14.0.0",
"@metamask/utils": "^11.4.2",
"@metamask/auto-changelog": "^5.3.0",
"@metamask/eslint-config": "^15.0.0",
"@metamask/eslint-config-nodejs": "^15.0.0",
"@metamask/eslint-config-typescript": "^15.0.0",
"@metamask/utils": "^11.9.0",
"@ocap/repo-tools": "workspace:^",
"@ts-bridge/cli": "^0.6.3",
"@ts-bridge/shims": "^0.1.1",
Expand Down
2 changes: 0 additions & 2 deletions packages/create-package/src/cli.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ function getParsedArgv(
description: string,
): Record<string, string | string[]> {
return {
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
_: [],
$0: 'create-package',
name: `@ocap/${name}`,
Expand Down
2 changes: 0 additions & 2 deletions packages/create-package/src/commands.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ describe('create-package/commands', () => {
});

const args: Arguments<CreatePackageOptions> = {
// TODO: Either fix this lint violation or explain why it's necessary to ignore.
// eslint-disable-next-line @typescript-eslint/naming-convention
_: [],
$0: 'create-package',
name: '@ocap/new-package',
Expand Down
10 changes: 5 additions & 5 deletions packages/extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,17 @@
"@metamask/logger": "workspace:^",
"@metamask/ocap-kernel": "workspace:^",
"@metamask/streams": "workspace:^",
"@metamask/utils": "^11.4.2",
"@metamask/utils": "^11.9.0",
"react": "^17.0.2",
"react-dom": "^17.0.2",
"ses": "^1.14.0"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.4",
"@metamask/auto-changelog": "^5.0.1",
"@metamask/eslint-config": "^14.0.0",
"@metamask/eslint-config-nodejs": "^14.0.0",
"@metamask/eslint-config-typescript": "^14.0.0",
"@metamask/auto-changelog": "^5.3.0",
"@metamask/eslint-config": "^15.0.0",
"@metamask/eslint-config-nodejs": "^15.0.0",
"@metamask/eslint-config-typescript": "^15.0.0",
"@ocap/cli": "workspace:^",
"@ocap/kernel-test": "workspace:^",
"@ocap/repo-tools": "workspace:^",
Expand Down
8 changes: 4 additions & 4 deletions packages/kernel-agents/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,10 @@
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.17.4",
"@metamask/auto-changelog": "^5.0.1",
"@metamask/eslint-config": "^14.0.0",
"@metamask/eslint-config-nodejs": "^14.0.0",
"@metamask/eslint-config-typescript": "^14.0.0",
"@metamask/auto-changelog": "^5.3.0",
"@metamask/eslint-config": "^15.0.0",
"@metamask/eslint-config-nodejs": "^15.0.0",
"@metamask/eslint-config-typescript": "^15.0.0",
"@ocap/repo-tools": "workspace:^",
"@ts-bridge/cli": "^0.6.3",
"@ts-bridge/shims": "^0.1.1",
Expand Down
53 changes: 53 additions & 0 deletions packages/kernel-agents/src/strategies/json/messages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ export type MessageType =
| 'assistant'
| 'capabilityResult';

/**
* A message with a type and body, used for structured communication in agent transcripts.
*/
export class Message<
Type extends MessageType,
Body extends Record<string, unknown>,
Expand All @@ -12,11 +15,22 @@ export class Message<

messageBody: Body;

/**
* Constructs a new {@link Message}.
*
* @param messageType - The type of the message.
* @param messageBody - The body content of the message.
*/
constructor(messageType: Type, messageBody: Body) {
this.messageType = messageType;
this.messageBody = messageBody;
}

/**
* Serializes the message to a JSON string.
*
* @returns The JSON string representation of the message.
*/
toJSON(): string {
return JSON.stringify({
...this.messageBody,
Expand All @@ -27,31 +41,62 @@ export class Message<

export type Transcript = Message<MessageType, Record<string, unknown>>[];

/**
* A message containing capability schemas for the agent to use.
*/
export class CapabilitySpecMessage extends Message<
'capabilitySpecification',
{ schemas: object }
> {
/**
* Constructs a new {@link CapabilitySpecMessage}.
*
* @param schemas - The capability schemas describing available capabilities.
*/
constructor(schemas: object) {
super('capabilitySpecification', { schemas });
}
}

/**
* A message representing user input to the agent.
*/
export class UserMessage extends Message<'user', { content: string }> {
/**
* Constructs a new {@link UserMessage}.
*
* @param content - The user's message content.
*/
constructor(content: string) {
super('user', { content });
}
}

export type Invocation = { name: string; args: object };

/**
* A message representing the assistant's response, including optional thinking and capability invocations.
*/
export class AssistantMessage extends Message<
'assistant',
{ think?: string[]; invoke: Invocation[] }
> {
/**
* Constructs a new {@link AssistantMessage}.
*
* @param options - The options for the assistant message.
* @param options.think - The think to include in the message.
* @param options.invoke - The invoke to include in the message.
*/
constructor({ think, invoke }: { think?: string[]; invoke: Invocation[] }) {
super('assistant', { think: think ?? [], invoke });
}

/**
* Serializes the assistant message to a JSON string.
*
* @returns The JSON string.
*/
toJSON(): string {
/* JSON.stringify will not preserve the order of the properties.
* To utilize the conditional probability, think precedes invoke.
Expand All @@ -72,10 +117,18 @@ export type AssistantMessageJson = {
invoke: Invocation[];
};

/**
* A message containing the results of capability invocations.
*/
export class CapabilityResultMessage extends Message<
'capabilityResult',
{ results: (Invocation & { result: unknown })[] }
> {
/**
* Constructs a new {@link CapabilityResultMessage}.
*
* @param results - The array of invocation results, each containing the invocation details and its result.
*/
constructor(results: (Invocation & { result: unknown })[]) {
super('capabilityResult', { results });
}
Expand Down
Loading
Loading