From 9c2bd8f9e2a38a52a7447f3ebea9c74607c50866 Mon Sep 17 00:00:00 2001 From: Alfredo Gallardo Date: Wed, 4 Oct 2023 13:36:09 -0500 Subject: [PATCH 01/14] - fix: refactor isLocalMessage to generalize use cases --- .github/workflows/pr-ci-healcheck.yml | 50 ++++++ .../src/utils/shinkai_message_handler.test.ts | 147 ++++++++++++++++++ .../src/utils/shinkai_message_handler.ts | 11 +- .../src/utils/wasm_helpers.test.ts | 3 +- .../src/wasm/ShinkaiNameWrapper.test.ts | 72 +++++++++ .../src/wasm/ShinkaiNameWrapper.ts | 12 ++ 6 files changed, 289 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/pr-ci-healcheck.yml create mode 100644 libs/shinkai-message-ts/src/utils/shinkai_message_handler.test.ts diff --git a/.github/workflows/pr-ci-healcheck.yml b/.github/workflows/pr-ci-healcheck.yml new file mode 100644 index 000000000..50a0dc08e --- /dev/null +++ b/.github/workflows/pr-ci-healcheck.yml @@ -0,0 +1,50 @@ +name: PR CI Health Check + +on: + pull_request: + branches: [ main ] + +defaults: + run: + working-directory: ./ + +jobs: + setup: + runs-on: ubuntu-latest + outputs: + packages: ${{ steps.filter.outputs.changes }} + steps: + - name: Check out repository + uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - name: Use nx set shas + uses: nrwl/nx-set-shas@v3 + + + - name: Setup Node version + uses: actions/setup-node@v3 + with: + node-version: 18 + check-latest: false + registry-url: https://registry.npmjs.org + cache: "npm" + cache-dependency-path: package-lock.json + + - name: Install dependencies + run: | + npm cache verify + npm ci --prefer-offline --no-audit + + healthchecks: + needs: setup + runs-on: ${{ matrix.target }} + strategy: + fail-fast: true + max-parallel: 1 + matrix: + target: ['lint', 'build', 'test'] + steps: + - name: nx ${{ matrix.target }} + run: npx nx affected -t ${{ matrix.target }} --parallel=3 diff --git a/libs/shinkai-message-ts/src/utils/shinkai_message_handler.test.ts b/libs/shinkai-message-ts/src/utils/shinkai_message_handler.test.ts new file mode 100644 index 000000000..8a3a19a84 --- /dev/null +++ b/libs/shinkai-message-ts/src/utils/shinkai_message_handler.test.ts @@ -0,0 +1,147 @@ +import { isLocalMessage } from './shinkai_message_handler'; + +describe('shinkai_messag_handler isLocalMessage', () => { + const messageSentByNode1MainDevice = `{ + "body": { + "unencrypted": { + "message_data": { + "unencrypted": { + "message_raw_content": "hey!", + "message_content_schema": "TextContent" + } + }, + "internal_metadata": { + "sender_subidentity": "main/device/main_device", + "recipient_subidentity": "", + "inbox": "inbox::@@node1.shinkai/main/device/main_device::@@node2.shinkai::false", + "signature": "", + "encryption": "None" + } + } + }, + "external_metadata": { + "sender": "@@node1.shinkai", + "recipient": "@@node2.shinkai", + "scheduled_time": "2023-08-25T22:44:01.132Z", + "signature": "c6d0115c0878fbf2279f98aab67c0e9cb1af63825f49dca48d6e4420eba0ceb973e00488ba0905c9afd09254f0dac48c468fdcb1d6c5ab5ca4c5dd70a440b903", + "other": "" + }, + "encryption": "DiffieHellmanChaChaPoly1305", + "version": "V1_0" + }`; + + const messageSentByNode1SecondaryDevice = `{ + "body": { + "unencrypted": { + "message_data": { + "unencrypted": { + "message_raw_content": "hey!", + "message_content_schema": "TextContent" + } + }, + "internal_metadata": { + "sender_subidentity": "main/device/secondary_device", + "recipient_subidentity": "", + "inbox": "inbox::@@node1.shinkai/main/device/secondary_device::@@node2.shinkai::false", + "signature": "", + "encryption": "None" + } + } + }, + "external_metadata": { + "sender": "@@node1.shinkai", + "recipient": "@@node2.shinkai", + "scheduled_time": "2023-08-25T22:44:01.132Z", + "signature": "c6d0115c0878fbf2279f98aab67c0e9cb1af63825f49dca48d6e4420eba0ceb973e00488ba0905c9afd09254f0dac48c468fdcb1d6c5ab5ca4c5dd70a440b903", + "other": "" + }, + "encryption": "DiffieHellmanChaChaPoly1305", + "version": "V1_0" + }`; + + const messageSentByNode1AgentGpt = `{ + "body": { + "unencrypted": { + "message_data": { + "unencrypted": { + "message_raw_content": "hey!", + "message_content_schema": "TextContent" + } + }, + "internal_metadata": { + "sender_subidentity": "main/agent/gpt", + "recipient_subidentity": "", + "inbox": "inbox::@@node1.shinkai/main/agent/gpt::@@node2.shinkai::false", + "signature": "", + "encryption": "None" + } + } + }, + "external_metadata": { + "sender": "@@node1.shinkai", + "recipient": "@@node2.shinkai", + "scheduled_time": "2023-08-25T22:44:01.132Z", + "signature": "c6d0115c0878fbf2279f98aab67c0e9cb1af63825f49dca48d6e4420eba0ceb973e00488ba0905c9afd09254f0dac48c468fdcb1d6c5ab5ca4c5dd70a440b903", + "other": "" + }, + "encryption": "DiffieHellmanChaChaPoly1305", + "version": "V1_0" + }`; + + const messageSentByNode2MainDevice = `{ + "body": { + "unencrypted": { + "message_data": { + "unencrypted": { + "message_raw_content": "hey!", + "message_content_schema": "TextContent" + } + }, + "internal_metadata": { + "sender_subidentity": "main/device/main_device", + "recipient_subidentity": "", + "inbox": "inbox::@@node2.shinkai/main/device/main_device::@@node1.shinkai::false", + "signature": "", + "encryption": "None" + } + } + }, + "external_metadata": { + "sender": "@@node2.shinkai", + "recipient": "@@node1.shinkai", + "scheduled_time": "2023-08-25T22:44:01.132Z", + "signature": "c6d0115c0878fbf2279f98aab67c0e9cb1af63825f49dca48d6e4420eba0ceb973e00488ba0905c9afd09254f0dac48c468fdcb1d6c5ab5ca4c5dd70a440b903", + "other": "" + }, + "encryption": "DiffieHellmanChaChaPoly1305", + "version": "V1_0" + }`; + + const myNodeSetup = { + myNodeIdentity: '@@node1.shinkai', + myProfile: 'main', + }; + it('false when message was sent by agent', () => { + const message = JSON.parse(messageSentByNode1AgentGpt); + const isLocal = isLocalMessage(message, myNodeSetup.myNodeIdentity, myNodeSetup.myProfile); + expect(isLocal).toBe(false); + }); + + it('false when message was sent by a different node', () => { + const message = JSON.parse(messageSentByNode2MainDevice); + const isLocal = isLocalMessage(message, myNodeSetup.myNodeIdentity, myNodeSetup.myProfile); + expect(isLocal).toBe(false); + }); + + it('true when message was sent by same node', () => { + const message = JSON.parse(messageSentByNode1MainDevice); + const isLocal = isLocalMessage(message, myNodeSetup.myNodeIdentity, myNodeSetup.myProfile); + expect(isLocal).toBe(true); + }); + + it('true when message was sent by same node but different device', () => { + const message = JSON.parse(messageSentByNode1SecondaryDevice); + const isLocal = isLocalMessage(message, myNodeSetup.myNodeIdentity, myNodeSetup.myProfile); + expect(isLocal).toBe(true); + }); +}); diff --git a/libs/shinkai-message-ts/src/utils/shinkai_message_handler.ts b/libs/shinkai-message-ts/src/utils/shinkai_message_handler.ts index 2bac1afe6..465fa4bc5 100644 --- a/libs/shinkai-message-ts/src/utils/shinkai_message_handler.ts +++ b/libs/shinkai-message-ts/src/utils/shinkai_message_handler.ts @@ -1,5 +1,6 @@ import { MessageSchemaType } from '../models/SchemaTypes'; import { ShinkaiMessage } from '../models/ShinkaiMessage'; +import { ShinkaiNameWrapper } from '../wasm'; import { ShinkaiMessageWrapper } from '../wasm/ShinkaiMessageWrapper'; export function calculateMessageHash(message: ShinkaiMessage): string { @@ -51,8 +52,10 @@ export const getMessageContent = (message: ShinkaiMessage) => { export const isLocalMessage = ( message: ShinkaiMessage, - identity: string, - profile: string, -) => { - return message.external_metadata?.sender === `${identity}/${profile}`; + myNodeIdentity: string, + myProfile: string, +): boolean => { + const messageNameWrapper = ShinkaiNameWrapper.from_shinkai_message_sender(message); + return messageNameWrapper.get_subidentity_type === 'device' && + messageNameWrapper.get_node_name === myNodeIdentity && messageNameWrapper.get_profile_name === myProfile; }; diff --git a/libs/shinkai-message-ts/src/utils/wasm_helpers.test.ts b/libs/shinkai-message-ts/src/utils/wasm_helpers.test.ts index 26b281f31..871ec9cb5 100644 --- a/libs/shinkai-message-ts/src/utils/wasm_helpers.test.ts +++ b/libs/shinkai-message-ts/src/utils/wasm_helpers.test.ts @@ -3,8 +3,7 @@ import { sha512 } from '@noble/hashes/sha512'; import { Crypto } from "@peculiar/webcrypto"; import { generateEncryptionKeys, generateSignatureKeys, test_util_generateKeys } from './wasm_helpers'; -console.log('PATATATATATATA2'); -console.log('PATATATATATATA');console.log('PATATATATATATA');console.log('PATATATATATATA');console.log('PATATATATATATA');console.log('PATATATATATATA');console.log('PATATATATATATA'); + // Enable synchronous methods ed.etc.sha512Sync = (...m) => sha512(ed.etc.concatBytes(...m)); diff --git a/libs/shinkai-message-ts/src/wasm/ShinkaiNameWrapper.test.ts b/libs/shinkai-message-ts/src/wasm/ShinkaiNameWrapper.test.ts index 48559881f..d064bac21 100644 --- a/libs/shinkai-message-ts/src/wasm/ShinkaiNameWrapper.test.ts +++ b/libs/shinkai-message-ts/src/wasm/ShinkaiNameWrapper.test.ts @@ -48,3 +48,75 @@ test("ShinkaiNameWrapper get_profile_name", () => { expect(wrapper.extract_profile().get_full_name).toBe(profile.toLowerCase()); } }); + +test("ShinkaiNameWrapper from_shinkai_message_sender", () => { + it('should fail when message is encrypted', () => { + const encryptedMessage = `{ + "body": { + "encrypted": { + "message_data": { + "unencrypted": { + "message_raw_content": "hey!", + "message_content_schema": "TextContent" + } + }, + "internal_metadata": { + "sender_subidentity": "main/device/main_device", + "recipient_subidentity": "", + "inbox": "inbox::@@node1.shinkai/main/device/main_device::@@node2.shinkai::false", + "signature": "", + "encryption": "None" + } + } + }, + "external_metadata": { + "sender": "@@node1.shinkai", + "recipient": "@@node2.shinkai", + "scheduled_time": "2023-08-25T22:44:01.132Z", + "signature": "c6d0115c0878fbf2279f98aab67c0e9cb1af63825f49dca48d6e4420eba0ceb973e00488ba0905c9afd09254f0dac48c468fdcb1d6c5ab5ca4c5dd70a440b903", + "other": "" + }, + "encryption": "DiffieHellmanChaChaPoly1305", + "version": "V1_0" + }`; + const message = JSON.parse(encryptedMessage); + expect(ShinkaiNameWrapper.from_shinkai_message_sender(message)).toThrowError(); + }); + + it('should fail when message is encrypted', () => { + const encryptedMessage = `{ + "body": { + "unencrypted": { + "message_data": { + "unencrypted": { + "message_raw_content": "hey!", + "message_content_schema": "TextContent" + } + }, + "internal_metadata": { + "sender_subidentity": "main/device/main_device", + "recipient_subidentity": "", + "inbox": "inbox::@@node1.shinkai/main/device/main_device::@@node2.shinkai::false", + "signature": "", + "encryption": "None" + } + } + }, + "external_metadata": { + "sender": "@@node1.shinkai", + "recipient": "@@node2.shinkai", + "scheduled_time": "2023-08-25T22:44:01.132Z", + "signature": "c6d0115c0878fbf2279f98aab67c0e9cb1af63825f49dca48d6e4420eba0ceb973e00488ba0905c9afd09254f0dac48c468fdcb1d6c5ab5ca4c5dd70a440b903", + "other": "" + }, + "encryption": "DiffieHellmanChaChaPoly1305", + "version": "V1_0" + }`; + const message = JSON.parse(encryptedMessage); + const messageNameWrapper = ShinkaiNameWrapper.from_shinkai_message_sender(message); + expect(messageNameWrapper.get_node_name).toBe('@@node1.shinkai'); + expect(messageNameWrapper.get_full_name).toBe('@@node1.shinkai/main/device/main_device'); + expect(messageNameWrapper.get_subidentity_name).toBe('main/device/main_device'); + expect(messageNameWrapper.get_subidentity_type).toBe('device'); + }); +}); diff --git a/libs/shinkai-message-ts/src/wasm/ShinkaiNameWrapper.ts b/libs/shinkai-message-ts/src/wasm/ShinkaiNameWrapper.ts index 3a35fb7e8..28c0a12a9 100644 --- a/libs/shinkai-message-ts/src/wasm/ShinkaiNameWrapper.ts +++ b/libs/shinkai-message-ts/src/wasm/ShinkaiNameWrapper.ts @@ -1,3 +1,4 @@ +import { ShinkaiMessage } from "../models"; import { ShinkaiNameWrapper as ShinkaiNameWrapperWASM } from "../pkg/shinkai_message_wasm"; export class ShinkaiNameWrapper { @@ -7,6 +8,17 @@ export class ShinkaiNameWrapper { this.wasmWrapper = new ShinkaiNameWrapperWASM(shinkai_name_js); } + static from_shinkai_message_sender(message: ShinkaiMessage): ShinkaiNameWrapper { + if (!message.body || !('unencrypted' in message.body)) { + throw new Error('shinkai message is encrypted'); + } + let name = message.external_metadata?.sender; + if (message.body.unencrypted.internal_metadata.sender_subidentity) { + name += `/${message.body.unencrypted.internal_metadata.sender_subidentity}`; + } + return new ShinkaiNameWrapper(name); + } + to_jsvalue(): any { return this.wasmWrapper.to_jsvalue(); } From 46973fda429a0b29ec8e24b3712bd2434d32783d Mon Sep 17 00:00:00 2001 From: Alfredo Gallardo Date: Wed, 4 Oct 2023 13:44:17 -0500 Subject: [PATCH 02/14] - fix: fixed typo in runs_on for nx --- .github/workflows/pr-ci-healcheck.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pr-ci-healcheck.yml b/.github/workflows/pr-ci-healcheck.yml index 50a0dc08e..7efb48e39 100644 --- a/.github/workflows/pr-ci-healcheck.yml +++ b/.github/workflows/pr-ci-healcheck.yml @@ -39,7 +39,7 @@ jobs: healthchecks: needs: setup - runs-on: ${{ matrix.target }} + runs-on: ubuntu-latest strategy: fail-fast: true max-parallel: 1 From 6f37a21b6ef691794f5cf2fc83bff5cc08f619e9 Mon Sep 17 00:00:00 2001 From: Alfredo Gallardo Date: Wed, 4 Oct 2023 14:06:30 -0500 Subject: [PATCH 03/14] - fix: pr healthcheck matrix --- .github/workflows/pr-ci-healcheck.yml | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/.github/workflows/pr-ci-healcheck.yml b/.github/workflows/pr-ci-healcheck.yml index 7efb48e39..ce787c2a5 100644 --- a/.github/workflows/pr-ci-healcheck.yml +++ b/.github/workflows/pr-ci-healcheck.yml @@ -9,21 +9,28 @@ defaults: working-directory: ./ jobs: - setup: + healthchecks: runs-on: ubuntu-latest - outputs: - packages: ${{ steps.filter.outputs.changes }} + strategy: + fail-fast: true + max-parallel: 1 + matrix: + target: ['lint', 'build', 'test'] + steps: - name: Check out repository + if: matrix.target != 'lint' uses: actions/checkout@v4 with: fetch-depth: 0 - name: Use nx set shas + if: matrix.target != 'lint' uses: nrwl/nx-set-shas@v3 - name: Setup Node version + if: matrix.target != 'lint' uses: actions/setup-node@v3 with: node-version: 18 @@ -33,18 +40,10 @@ jobs: cache-dependency-path: package-lock.json - name: Install dependencies + if: matrix.target != 'lint' run: | npm cache verify npm ci --prefer-offline --no-audit - healthchecks: - needs: setup - runs-on: ubuntu-latest - strategy: - fail-fast: true - max-parallel: 1 - matrix: - target: ['lint', 'build', 'test'] - steps: - - name: nx ${{ matrix.target }} + - name: Run NX target ${{ matrix.target }} on affected projects run: npx nx affected -t ${{ matrix.target }} --parallel=3 From 0afa8cc9bc0236230c402dbf1fb72d656f71ee23 Mon Sep 17 00:00:00 2001 From: Alfredo Gallardo Date: Wed, 4 Oct 2023 14:16:29 -0500 Subject: [PATCH 04/14] - fix: typo in matrix condition --- .github/workflows/pr-ci-healcheck.yml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pr-ci-healcheck.yml b/.github/workflows/pr-ci-healcheck.yml index ce787c2a5..ec3ac6c45 100644 --- a/.github/workflows/pr-ci-healcheck.yml +++ b/.github/workflows/pr-ci-healcheck.yml @@ -19,18 +19,18 @@ jobs: steps: - name: Check out repository - if: matrix.target != 'lint' + if: matrix.target == 'lint' uses: actions/checkout@v4 with: fetch-depth: 0 - name: Use nx set shas - if: matrix.target != 'lint' + if: matrix.target == 'lint' uses: nrwl/nx-set-shas@v3 - name: Setup Node version - if: matrix.target != 'lint' + if: matrix.target == 'lint' uses: actions/setup-node@v3 with: node-version: 18 @@ -40,7 +40,7 @@ jobs: cache-dependency-path: package-lock.json - name: Install dependencies - if: matrix.target != 'lint' + if: matrix.target == 'lint' run: | npm cache verify npm ci --prefer-offline --no-audit From dd59d5b44d6562c096a6fd5e66acb58d5a03096f Mon Sep 17 00:00:00 2001 From: Alfredo Gallardo Date: Wed, 4 Oct 2023 14:29:03 -0500 Subject: [PATCH 05/14] - fix: fixed eslint error --- .eslintrc.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.eslintrc.json b/.eslintrc.json index d4a5e608c..78a33fc1c 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -7,7 +7,8 @@ "react/react-in-jsx-scope": "off", "react/jsx-uses-react": "off", "simple-import-sort/imports": "error", - "react/jsx-sort-props": "warn" + "react/jsx-sort-props": "warn", + "react/prop-types": "off" }, "overrides": [ { From ecf5a2da30ff0a4116a21198ee79f284d47a2cf5 Mon Sep 17 00:00:00 2001 From: Alfredo Gallardo Date: Wed, 4 Oct 2023 14:32:54 -0500 Subject: [PATCH 06/14] - fix: ci matrix --- .github/workflows/pr-ci-healcheck.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/pr-ci-healcheck.yml b/.github/workflows/pr-ci-healcheck.yml index ec3ac6c45..c2a0c3a20 100644 --- a/.github/workflows/pr-ci-healcheck.yml +++ b/.github/workflows/pr-ci-healcheck.yml @@ -19,18 +19,15 @@ jobs: steps: - name: Check out repository - if: matrix.target == 'lint' uses: actions/checkout@v4 with: fetch-depth: 0 - name: Use nx set shas - if: matrix.target == 'lint' uses: nrwl/nx-set-shas@v3 - name: Setup Node version - if: matrix.target == 'lint' uses: actions/setup-node@v3 with: node-version: 18 @@ -40,7 +37,6 @@ jobs: cache-dependency-path: package-lock.json - name: Install dependencies - if: matrix.target == 'lint' run: | npm cache verify npm ci --prefer-offline --no-audit From 56fb0dfafef4789d6b3ee4b0c6d5272d4c17752c Mon Sep 17 00:00:00 2001 From: Alfredo Gallardo Date: Wed, 4 Oct 2023 14:58:44 -0500 Subject: [PATCH 07/14] - improve: improvements from pr feedback --- .../src/utils/shinkai_message_handler.test.ts | 2 +- .../src/utils/shinkai_message_handler.ts | 2 +- .../src/wasm/ShinkaiNameWrapper.test.ts | 26 +++++-------------- .../src/wasm/ShinkaiNameWrapper.ts | 5 +++- 4 files changed, 13 insertions(+), 22 deletions(-) diff --git a/libs/shinkai-message-ts/src/utils/shinkai_message_handler.test.ts b/libs/shinkai-message-ts/src/utils/shinkai_message_handler.test.ts index 8a3a19a84..36a68c054 100644 --- a/libs/shinkai-message-ts/src/utils/shinkai_message_handler.test.ts +++ b/libs/shinkai-message-ts/src/utils/shinkai_message_handler.test.ts @@ -71,7 +71,7 @@ describe('shinkai_messag_handler isLocalMessage', () => { "internal_metadata": { "sender_subidentity": "main/agent/gpt", "recipient_subidentity": "", - "inbox": "inbox::@@node1.shinkai/main/agent/gpt::@@node2.shinkai::false", + "inbox": "job_inbox::@@node1.shinkai/main/agent/gpt::@@node2.shinkai::false", "signature": "", "encryption": "None" } diff --git a/libs/shinkai-message-ts/src/utils/shinkai_message_handler.ts b/libs/shinkai-message-ts/src/utils/shinkai_message_handler.ts index 465fa4bc5..71ad287a5 100644 --- a/libs/shinkai-message-ts/src/utils/shinkai_message_handler.ts +++ b/libs/shinkai-message-ts/src/utils/shinkai_message_handler.ts @@ -56,6 +56,6 @@ export const isLocalMessage = ( myProfile: string, ): boolean => { const messageNameWrapper = ShinkaiNameWrapper.from_shinkai_message_sender(message); - return messageNameWrapper.get_subidentity_type === 'device' && + return messageNameWrapper.get_subidentity_type === 'None' || messageNameWrapper.get_subidentity_type === 'device' && messageNameWrapper.get_node_name === myNodeIdentity && messageNameWrapper.get_profile_name === myProfile; }; diff --git a/libs/shinkai-message-ts/src/wasm/ShinkaiNameWrapper.test.ts b/libs/shinkai-message-ts/src/wasm/ShinkaiNameWrapper.test.ts index d064bac21..8c2bd740b 100644 --- a/libs/shinkai-message-ts/src/wasm/ShinkaiNameWrapper.test.ts +++ b/libs/shinkai-message-ts/src/wasm/ShinkaiNameWrapper.test.ts @@ -83,30 +83,18 @@ test("ShinkaiNameWrapper from_shinkai_message_sender", () => { expect(ShinkaiNameWrapper.from_shinkai_message_sender(message)).toThrowError(); }); - it('should fail when message is encrypted', () => { + it('should fail when message is first level encrypted', () => { const encryptedMessage = `{ "body": { - "unencrypted": { - "message_data": { - "unencrypted": { - "message_raw_content": "hey!", - "message_content_schema": "TextContent" - } - }, - "internal_metadata": { - "sender_subidentity": "main/device/main_device", - "recipient_subidentity": "", - "inbox": "inbox::@@node1.shinkai/main/device/main_device::@@node2.shinkai::false", - "signature": "", - "encryption": "None" - } + "encrypted": { + "content": "encrypted:de9a22018a78cb1977d72936145576a4e040a590c5da6ac9f60f334c5fddd773b53ca11c5a97110e4352a694fa55632e9e07346e60a579171aea11fcf17a8e9666fe8f3bfddadafe5b2ecef5b8d7759979536e8ae848c1976a5057892836d0a5806fdaf4a30220217da2f4930914aea7b1f0f4ae65175ca9d24db4408294ca4b7347048a295ef5eeac1f3a60112953edf3f78bd02103fc9ae866cbb223385781218f0c021e41c79f529b7fd8748d8339db1cc0e03ae7d3b27b6147639cc01f44e594401bea76743ddefff47e737df61710c30fc7e5f38da306336cf668c198dfa2f90506" } }, "external_metadata": { - "sender": "@@node1.shinkai", - "recipient": "@@node2.shinkai", - "scheduled_time": "2023-08-25T22:44:01.132Z", - "signature": "c6d0115c0878fbf2279f98aab67c0e9cb1af63825f49dca48d6e4420eba0ceb973e00488ba0905c9afd09254f0dac48c468fdcb1d6c5ab5ca4c5dd70a440b903", + "sender": "@@node1.shinkai/main", + "recipient": "@@node1.shinkai", + "scheduled_time": "2023-10-04T19:38:50.271Z", + "signature": "028810426c653e993deea94aa08b8fec14e82040ba73b09e533726eb769ea5de87ba095cc83cfe35035ca2db1ce996c963b7e7b12b1a28240706e4e0cbef6904", "other": "" }, "encryption": "DiffieHellmanChaChaPoly1305", diff --git a/libs/shinkai-message-ts/src/wasm/ShinkaiNameWrapper.ts b/libs/shinkai-message-ts/src/wasm/ShinkaiNameWrapper.ts index 28c0a12a9..6f1089156 100644 --- a/libs/shinkai-message-ts/src/wasm/ShinkaiNameWrapper.ts +++ b/libs/shinkai-message-ts/src/wasm/ShinkaiNameWrapper.ts @@ -9,9 +9,12 @@ export class ShinkaiNameWrapper { } static from_shinkai_message_sender(message: ShinkaiMessage): ShinkaiNameWrapper { - if (!message.body || !('unencrypted' in message.body)) { + if (message.encryption !== 'None') { throw new Error('shinkai message is encrypted'); } + if (!message.body || !('unencrypted' in message.body)) { + throw new Error('shinkai message body doesn\'t conestains unencrypted property'); + } let name = message.external_metadata?.sender; if (message.body.unencrypted.internal_metadata.sender_subidentity) { name += `/${message.body.unencrypted.internal_metadata.sender_subidentity}`; From a55d6c2bddd81e9f5f54bd07ebf88a2a3bf63114 Mon Sep 17 00:00:00 2001 From: Alfredo Gallardo Date: Wed, 4 Oct 2023 15:00:35 -0500 Subject: [PATCH 08/14] - fix: removed unused case --- libs/shinkai-message-ts/src/utils/shinkai_message_handler.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libs/shinkai-message-ts/src/utils/shinkai_message_handler.ts b/libs/shinkai-message-ts/src/utils/shinkai_message_handler.ts index 71ad287a5..5f9db4580 100644 --- a/libs/shinkai-message-ts/src/utils/shinkai_message_handler.ts +++ b/libs/shinkai-message-ts/src/utils/shinkai_message_handler.ts @@ -56,6 +56,5 @@ export const isLocalMessage = ( myProfile: string, ): boolean => { const messageNameWrapper = ShinkaiNameWrapper.from_shinkai_message_sender(message); - return messageNameWrapper.get_subidentity_type === 'None' || messageNameWrapper.get_subidentity_type === 'device' && - messageNameWrapper.get_node_name === myNodeIdentity && messageNameWrapper.get_profile_name === myProfile; + return messageNameWrapper.get_node_name === myNodeIdentity && messageNameWrapper.get_profile_name === myProfile; }; From 637ca8c9bd54f028c9eee06a848e52d6508d13f7 Mon Sep 17 00:00:00 2001 From: Alfredo Gallardo Date: Wed, 4 Oct 2023 18:36:39 -0500 Subject: [PATCH 09/14] - fix: test if removing --prefer-offline solves build problem --- .../workflows/{pr-ci-healcheck.yml => pr-ci-healchecks.yml} | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) rename .github/workflows/{pr-ci-healcheck.yml => pr-ci-healchecks.yml} (91%) diff --git a/.github/workflows/pr-ci-healcheck.yml b/.github/workflows/pr-ci-healchecks.yml similarity index 91% rename from .github/workflows/pr-ci-healcheck.yml rename to .github/workflows/pr-ci-healchecks.yml index c2a0c3a20..dee75582a 100644 --- a/.github/workflows/pr-ci-healcheck.yml +++ b/.github/workflows/pr-ci-healchecks.yml @@ -1,4 +1,4 @@ -name: PR CI Health Check +name: PR CI Health checks on: pull_request: @@ -9,7 +9,7 @@ defaults: working-directory: ./ jobs: - healthchecks: + health-checks: runs-on: ubuntu-latest strategy: fail-fast: true @@ -39,7 +39,7 @@ jobs: - name: Install dependencies run: | npm cache verify - npm ci --prefer-offline --no-audit + npm ci --no-audit --verbose - name: Run NX target ${{ matrix.target }} on affected projects run: npx nx affected -t ${{ matrix.target }} --parallel=3 From 601d5198b4d4b3c79060098edc1c554a84f27ecd Mon Sep 17 00:00:00 2001 From: Alfredo Gallardo Date: Wed, 4 Oct 2023 18:42:16 -0500 Subject: [PATCH 10/14] - fix: added verbose to ci --- .github/workflows/pr-ci-healchecks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-ci-healchecks.yml b/.github/workflows/pr-ci-healchecks.yml index dee75582a..3e90cd593 100644 --- a/.github/workflows/pr-ci-healchecks.yml +++ b/.github/workflows/pr-ci-healchecks.yml @@ -39,7 +39,7 @@ jobs: - name: Install dependencies run: | npm cache verify - npm ci --no-audit --verbose + npm ci --no-audit - name: Run NX target ${{ matrix.target }} on affected projects - run: npx nx affected -t ${{ matrix.target }} --parallel=3 + run: npx nx affected -t ${{ matrix.target }} --parallel=3 --verbose From e35536cd5eae21747b8b2a89bd09aa9a03a3307c Mon Sep 17 00:00:00 2001 From: Alfredo Gallardo Date: Wed, 4 Oct 2023 19:08:58 -0500 Subject: [PATCH 11/14] - fix: added swc bindings --- package-lock.json | 268 +++++++++++++++++++++++++++++++++++++++++++++- package.json | 9 ++ 2 files changed, 276 insertions(+), 1 deletion(-) diff --git a/package-lock.json b/package-lock.json index 2dda3da1d..3f0f7da31 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,6 +31,13 @@ "@radix-ui/react-separator": "^1.0.3", "@radix-ui/react-slot": "^1.0.2", "@reduxjs/toolkit": "^1.9.5", + "@swc/core-darwin-arm64": "*", + "@swc/core-darwin-x64": "*", + "@swc/core-linux-arm-gnueabihf": "*", + "@swc/core-linux-arm64-gnu": "*", + "@swc/core-linux-arm64-musl": "*", + "@swc/core-linux-x64-gnu": "*", + "@swc/core-linux-x64-musl": "*", "@swc/helpers": "~0.5.0", "@uidotdev/usehooks": "^2.2.0", "@uiw/react-json-view": "^1.8.5", @@ -156,6 +163,15 @@ "engines": { "node": "18", "npm": "9" + }, + "optionalDependencies": { + "@swc/core-darwin-arm64": "^1.3.91", + "@swc/core-darwin-x64": "^1.3.91", + "@swc/core-linux-arm-gnueabihf": "^1.3.91", + "@swc/core-linux-arm64-gnu": "^1.3.91", + "@swc/core-linux-arm64-musl": "^1.3.91", + "@swc/core-linux-x64-gnu": "^1.3.91", + "@swc/core-linux-x64-musl": "^1.3.91" } }, "../shinkai-message-ts": { @@ -6678,12 +6694,166 @@ } }, "node_modules/@swc/core-darwin-arm64": { + "version": "1.3.91", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.91.tgz", + "integrity": "sha512-7kHGiQ1he5khcEeJuHDmLZPM3rRL/ith5OTmV6bOPsoHi46kLeixORW+ts1opC3tC9vu6xbk16xgX0QAJchc1w==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-darwin-x64": { + "version": "1.3.91", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.91.tgz", + "integrity": "sha512-8SpU18FbFpZDVzsHsAwdI1thF/picQGxq9UFxa8W+T9SDnbsqwFJv/6RqKJeJoDV6qFdl2OLjuO0OL7xrp0qnQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm-gnueabihf": { + "version": "1.3.91", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.91.tgz", + "integrity": "sha512-fOq4Cy8UbwX1yf0WB0d8hWZaIKCnPtPGguRqdXGLfwvhjZ9SIErT6PnmGTGRbQCNCIkOZWHKyTU0r8t2dN3haQ==", + "cpu": [ + "arm" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-gnu": { + "version": "1.3.91", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.91.tgz", + "integrity": "sha512-fki4ioRP/Esy4vdp8T34RCV+V9dqkRmOt763pf74pdiyFV2dPLXa5lnw/XvR1RTfPGknrYgjEQLCfZlReTryRw==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-arm64-musl": { + "version": "1.3.91", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.91.tgz", + "integrity": "sha512-XrG+DUUqNtfVLcJ20imby7fpBwQNG5VsEQBzQndSonPyUOa2YkTbBb60YDondfQGDABopuHH8gHN8o2H2/VCnQ==", + "cpu": [ + "arm64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-gnu": { + "version": "1.3.91", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.91.tgz", + "integrity": "sha512-d11bYhX+YPBr/Frcjc6eVn3C0LuS/9U1Li9EmQ+6s9EpYtYRl2ygSlC8eueLbaiazBnCVYFnc8bU4o0kc5B9sw==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-linux-x64-musl": { + "version": "1.3.91", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.91.tgz", + "integrity": "sha512-2SRp5Dke2P4jCQePkDx9trkkTstnRpZJVw5r3jvYdk0zeO6iC4+ZPvvoWXJLigqQv/fZnIiSUfJ6ssOoaEqTzQ==", + "cpu": [ + "x64" + ], + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-arm64-msvc": { "version": "1.3.82", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.82.tgz", + "integrity": "sha512-TR3MHKhDYIyGyFcyl2d/p1ftceXcubAhX5wRSOdtOyr5+K/v3jbyCCqN7bbqO5o43wQVCwwR/drHleYyDZvg8Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-ia32-msvc": { + "version": "1.3.82", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.82.tgz", + "integrity": "sha512-ZX4HzVVt6hs84YUg70UvyBJnBOIspmQQM0iXSzBvOikk3zRoN7BnDwQH4GScvevCEBuou60+i4I6d5kHLOfh8Q==", + "cpu": [ + "ia32" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core-win32-x64-msvc": { + "version": "1.3.82", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.82.tgz", + "integrity": "sha512-4mJMnex21kbQoaHeAmHnVwQN9/XAfPszJ6n9HI7SVH+aAHnbBIR0M59/b50/CJMjTj5niUGk7EwQ3nhVNOG32g==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core/node_modules/@swc/core-darwin-arm64": { + "version": "1.3.82", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.82.tgz", + "integrity": "sha512-JfsyDW34gVKD3uE0OUpUqYvAD3yseEaicnFP6pB292THtLJb0IKBBnK50vV/RzEJtc1bR3g1kNfxo2PeurZTrA==", "cpu": [ "arm64" ], "dev": true, - "license": "Apache-2.0 AND MIT", "optional": true, "os": [ "darwin" @@ -6692,6 +6862,102 @@ "node": ">=10" } }, + "node_modules/@swc/core/node_modules/@swc/core-darwin-x64": { + "version": "1.3.82", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.82.tgz", + "integrity": "sha512-ogQWgNMq7qTpITjcP3dnzkFNj7bh6SwMr859GvtOTrE75H7L7jDWxESfH4f8foB/LGxBKiDNmxKhitCuAsZK4A==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core/node_modules/@swc/core-linux-arm-gnueabihf": { + "version": "1.3.82", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.82.tgz", + "integrity": "sha512-7TMXG1lXlNhD0kUiEqs+YlGV4irAdBa2quuy+XI3oJf2fBK6dQfEq4xBy65B3khrorzQS3O0oDGQ+cmdpHExHA==", + "cpu": [ + "arm" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core/node_modules/@swc/core-linux-arm64-gnu": { + "version": "1.3.82", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.82.tgz", + "integrity": "sha512-26JkOujbzcItPAmIbD5vHJxQVy5ihcSu3YHTKwope1h28sApZdtE7S3e2G3gsZRTIdsCQkXUtAQeqHxGWWR3pw==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core/node_modules/@swc/core-linux-arm64-musl": { + "version": "1.3.82", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.82.tgz", + "integrity": "sha512-8Izj9tuuMpoc3cqiPBRtwqpO1BZ/+sfZVsEhLxrbOFlcSb8LnKyMle1g3JMMUwI4EU75RGVIzZMn8A6GOKdJbA==", + "cpu": [ + "arm64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core/node_modules/@swc/core-linux-x64-gnu": { + "version": "1.3.82", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.82.tgz", + "integrity": "sha512-0GSrIBScQwTaPv46T2qB7XnDYxndRCpwH4HMjh6FN+I+lfPUhTSJKW8AonqrqT1TbpFIgvzQs7EnTsD7AnSCow==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, + "node_modules/@swc/core/node_modules/@swc/core-linux-x64-musl": { + "version": "1.3.82", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.82.tgz", + "integrity": "sha512-KJUnaaepDKNzrEbwz4jv0iC3/t9x0NSoe06fnkAlhh2+NFKWKKJhVCOBTrpds8n7eylBDIXUlK34XQafjVMUdg==", + "cpu": [ + "x64" + ], + "dev": true, + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=10" + } + }, "node_modules/@swc/helpers": { "version": "0.5.1", "license": "Apache-2.0", diff --git a/package.json b/package.json index 6ad42f32a..3142bafb4 100644 --- a/package.json +++ b/package.json @@ -153,5 +153,14 @@ "engines": { "node": "18", "npm": "9" + }, + "optionalDependencies": { + "@swc/core-darwin-arm64": "^1.3.91", + "@swc/core-darwin-x64": "^1.3.91", + "@swc/core-linux-arm-gnueabihf": "^1.3.91", + "@swc/core-linux-arm64-gnu": "^1.3.91", + "@swc/core-linux-arm64-musl": "^1.3.91", + "@swc/core-linux-x64-gnu": "^1.3.91", + "@swc/core-linux-x64-musl": "^1.3.91" } } From b37596db890c7cf80d5ca0710df42e113b5b9e17 Mon Sep 17 00:00:00 2001 From: Alfredo Gallardo Date: Wed, 4 Oct 2023 19:16:13 -0500 Subject: [PATCH 12/14] - fix: set specific version of swc --- package-lock.json | 94 ++++++++++++++++++++++------------------------- package.json | 2 +- 2 files changed, 45 insertions(+), 51 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3f0f7da31..ebb27dc44 100644 --- a/package-lock.json +++ b/package-lock.json @@ -31,13 +31,6 @@ "@radix-ui/react-separator": "^1.0.3", "@radix-ui/react-slot": "^1.0.2", "@reduxjs/toolkit": "^1.9.5", - "@swc/core-darwin-arm64": "*", - "@swc/core-darwin-x64": "*", - "@swc/core-linux-arm-gnueabihf": "*", - "@swc/core-linux-arm64-gnu": "*", - "@swc/core-linux-arm64-musl": "*", - "@swc/core-linux-x64-gnu": "*", - "@swc/core-linux-x64-musl": "*", "@swc/helpers": "~0.5.0", "@uidotdev/usehooks": "^2.2.0", "@uiw/react-json-view": "^1.8.5", @@ -104,7 +97,7 @@ "@pmmmwh/react-refresh-webpack-plugin": "^0.5.7", "@svgr/webpack": "^8.0.1", "@swc/cli": "~0.1.62", - "@swc/core": "~1.3.51", + "@swc/core": "^1.3.83", "@testing-library/jest-dom": "^6.1.2", "@testing-library/react": "14.0.0", "@testing-library/user-event": "^14.4.3", @@ -6658,10 +6651,11 @@ } }, "node_modules/@swc/core": { - "version": "1.3.82", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.83.tgz", + "integrity": "sha512-PccHDgGQlFjpExgJxH91qA3a4aifR+axCFJ4RieCoiI0m5gURE4nBhxzTBY5YU/YKTBmPO8Gc5Q6inE3+NquWg==", "dev": true, "hasInstallScript": true, - "license": "Apache-2.0", "dependencies": { "@swc/types": "^0.1.4" }, @@ -6673,16 +6667,16 @@ "url": "https://opencollective.com/swc" }, "optionalDependencies": { - "@swc/core-darwin-arm64": "1.3.82", - "@swc/core-darwin-x64": "1.3.82", - "@swc/core-linux-arm-gnueabihf": "1.3.82", - "@swc/core-linux-arm64-gnu": "1.3.82", - "@swc/core-linux-arm64-musl": "1.3.82", - "@swc/core-linux-x64-gnu": "1.3.82", - "@swc/core-linux-x64-musl": "1.3.82", - "@swc/core-win32-arm64-msvc": "1.3.82", - "@swc/core-win32-ia32-msvc": "1.3.82", - "@swc/core-win32-x64-msvc": "1.3.82" + "@swc/core-darwin-arm64": "1.3.83", + "@swc/core-darwin-x64": "1.3.83", + "@swc/core-linux-arm-gnueabihf": "1.3.83", + "@swc/core-linux-arm64-gnu": "1.3.83", + "@swc/core-linux-arm64-musl": "1.3.83", + "@swc/core-linux-x64-gnu": "1.3.83", + "@swc/core-linux-x64-musl": "1.3.83", + "@swc/core-win32-arm64-msvc": "1.3.83", + "@swc/core-win32-ia32-msvc": "1.3.83", + "@swc/core-win32-x64-msvc": "1.3.83" }, "peerDependencies": { "@swc/helpers": "^0.5.0" @@ -6799,9 +6793,9 @@ } }, "node_modules/@swc/core-win32-arm64-msvc": { - "version": "1.3.82", - "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.82.tgz", - "integrity": "sha512-TR3MHKhDYIyGyFcyl2d/p1ftceXcubAhX5wRSOdtOyr5+K/v3jbyCCqN7bbqO5o43wQVCwwR/drHleYyDZvg8Q==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.83.tgz", + "integrity": "sha512-yw2rd/KVOGs95lRRB+killLWNaO1dy4uVa8Q3/4wb5txlLru07W1m041fZLzwOg/1Sh0TMjJgGxj0XHGR3ZXhQ==", "cpu": [ "arm64" ], @@ -6815,9 +6809,9 @@ } }, "node_modules/@swc/core-win32-ia32-msvc": { - "version": "1.3.82", - "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.82.tgz", - "integrity": "sha512-ZX4HzVVt6hs84YUg70UvyBJnBOIspmQQM0iXSzBvOikk3zRoN7BnDwQH4GScvevCEBuou60+i4I6d5kHLOfh8Q==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.83.tgz", + "integrity": "sha512-POW+rgZ6KWqBpwPGIRd2/3pcf46P+UrKBm4HLt5IwbHvekJ4avIM8ixJa9kK0muJNVJcDpaZgxaU1ELxtJ1j8w==", "cpu": [ "ia32" ], @@ -6831,9 +6825,9 @@ } }, "node_modules/@swc/core-win32-x64-msvc": { - "version": "1.3.82", - "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.82.tgz", - "integrity": "sha512-4mJMnex21kbQoaHeAmHnVwQN9/XAfPszJ6n9HI7SVH+aAHnbBIR0M59/b50/CJMjTj5niUGk7EwQ3nhVNOG32g==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.83.tgz", + "integrity": "sha512-CiWQtkFnZElXQUalaHp+Wacw0Jd+24ncRYhqaJ9YKnEQP1H82CxIIuQqLM8IFaLpn5dpY6SgzaeubWF46hjcLA==", "cpu": [ "x64" ], @@ -6847,9 +6841,9 @@ } }, "node_modules/@swc/core/node_modules/@swc/core-darwin-arm64": { - "version": "1.3.82", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.82.tgz", - "integrity": "sha512-JfsyDW34gVKD3uE0OUpUqYvAD3yseEaicnFP6pB292THtLJb0IKBBnK50vV/RzEJtc1bR3g1kNfxo2PeurZTrA==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.83.tgz", + "integrity": "sha512-Plz2IKeveVLivbXTSCC3OZjD2MojyKYllhPrn9RotkDIZEFRYJZtW5/Ik1tJW/2rzu5HVKuGYrDKdScVVTbOxQ==", "cpu": [ "arm64" ], @@ -6863,9 +6857,9 @@ } }, "node_modules/@swc/core/node_modules/@swc/core-darwin-x64": { - "version": "1.3.82", - "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.82.tgz", - "integrity": "sha512-ogQWgNMq7qTpITjcP3dnzkFNj7bh6SwMr859GvtOTrE75H7L7jDWxESfH4f8foB/LGxBKiDNmxKhitCuAsZK4A==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.83.tgz", + "integrity": "sha512-FBGVg5IPF/8jQ6FbK60iDUHjv0H5+LwfpJHKH6wZnRaYWFtm7+pzYgreLu3NTsm3m7/1a7t0+7KURwBGUaJCCw==", "cpu": [ "x64" ], @@ -6879,9 +6873,9 @@ } }, "node_modules/@swc/core/node_modules/@swc/core-linux-arm-gnueabihf": { - "version": "1.3.82", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.82.tgz", - "integrity": "sha512-7TMXG1lXlNhD0kUiEqs+YlGV4irAdBa2quuy+XI3oJf2fBK6dQfEq4xBy65B3khrorzQS3O0oDGQ+cmdpHExHA==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.83.tgz", + "integrity": "sha512-EZcsuRYhGkzofXtzwDjuuBC/suiX9s7zeg2YYXOVjWwyebb6BUhB1yad3mcykFQ20rTLO9JUyIaiaMYDHGobqw==", "cpu": [ "arm" ], @@ -6895,9 +6889,9 @@ } }, "node_modules/@swc/core/node_modules/@swc/core-linux-arm64-gnu": { - "version": "1.3.82", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.82.tgz", - "integrity": "sha512-26JkOujbzcItPAmIbD5vHJxQVy5ihcSu3YHTKwope1h28sApZdtE7S3e2G3gsZRTIdsCQkXUtAQeqHxGWWR3pw==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.83.tgz", + "integrity": "sha512-khI41szLHrCD/cFOcN4p2SYvZgHjhhHlcMHz5BksRrDyteSJKu0qtWRZITVom0N/9jWoAleoFhMnFTUs0H8IWA==", "cpu": [ "arm64" ], @@ -6911,9 +6905,9 @@ } }, "node_modules/@swc/core/node_modules/@swc/core-linux-arm64-musl": { - "version": "1.3.82", - "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.82.tgz", - "integrity": "sha512-8Izj9tuuMpoc3cqiPBRtwqpO1BZ/+sfZVsEhLxrbOFlcSb8LnKyMle1g3JMMUwI4EU75RGVIzZMn8A6GOKdJbA==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.83.tgz", + "integrity": "sha512-zgT7yNOdbjHcGAwvys79mbfNLK65KBlPJWzeig+Yk7I8TVzmaQge7B6ZS/gwF9/p+8TiLYo/tZ5aF2lqlgdSVw==", "cpu": [ "arm64" ], @@ -6927,9 +6921,9 @@ } }, "node_modules/@swc/core/node_modules/@swc/core-linux-x64-gnu": { - "version": "1.3.82", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.82.tgz", - "integrity": "sha512-0GSrIBScQwTaPv46T2qB7XnDYxndRCpwH4HMjh6FN+I+lfPUhTSJKW8AonqrqT1TbpFIgvzQs7EnTsD7AnSCow==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.83.tgz", + "integrity": "sha512-x+mH0Y3NC/G0YNlFmGi3vGD4VOm7IPDhh+tGrx6WtJp0BsShAbOpxtfU885rp1QweZe4qYoEmGqiEjE2WrPIdA==", "cpu": [ "x64" ], @@ -6943,9 +6937,9 @@ } }, "node_modules/@swc/core/node_modules/@swc/core-linux-x64-musl": { - "version": "1.3.82", - "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.82.tgz", - "integrity": "sha512-KJUnaaepDKNzrEbwz4jv0iC3/t9x0NSoe06fnkAlhh2+NFKWKKJhVCOBTrpds8n7eylBDIXUlK34XQafjVMUdg==", + "version": "1.3.83", + "resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.83.tgz", + "integrity": "sha512-s5AYhAOmetUwUZwS5g9qb92IYgNHHBGiY2mTLImtEgpAeBwe0LPDj6WrujxCBuZnaS55mKRLLOuiMZE5TpjBNA==", "cpu": [ "x64" ], diff --git a/package.json b/package.json index 3142bafb4..c2549df13 100644 --- a/package.json +++ b/package.json @@ -29,7 +29,7 @@ "@pmmmwh/react-refresh-webpack-plugin": "^0.5.7", "@svgr/webpack": "^8.0.1", "@swc/cli": "~0.1.62", - "@swc/core": "~1.3.51", + "@swc/core": "^1.3.83", "@testing-library/jest-dom": "^6.1.2", "@testing-library/react": "14.0.0", "@testing-library/user-event": "^14.4.3", From 7334986bae29354937152e2bc31b743cb4f7fe9a Mon Sep 17 00:00:00 2001 From: Alfredo Gallardo Date: Wed, 4 Oct 2023 19:45:42 -0500 Subject: [PATCH 13/14] - fix: added condition to support subidentity_type --- .../src/utils/shinkai_message_handler.test.ts | 8 ++-- .../src/utils/shinkai_message_handler.ts | 3 +- .../src/wasm/ShinkaiNameWrapper.test.ts | 48 +++++++++---------- 3 files changed, 30 insertions(+), 29 deletions(-) diff --git a/libs/shinkai-message-ts/src/utils/shinkai_message_handler.test.ts b/libs/shinkai-message-ts/src/utils/shinkai_message_handler.test.ts index 36a68c054..fc0313b42 100644 --- a/libs/shinkai-message-ts/src/utils/shinkai_message_handler.test.ts +++ b/libs/shinkai-message-ts/src/utils/shinkai_message_handler.test.ts @@ -26,7 +26,7 @@ describe('shinkai_messag_handler isLocalMessage', () => { "signature": "c6d0115c0878fbf2279f98aab67c0e9cb1af63825f49dca48d6e4420eba0ceb973e00488ba0905c9afd09254f0dac48c468fdcb1d6c5ab5ca4c5dd70a440b903", "other": "" }, - "encryption": "DiffieHellmanChaChaPoly1305", + "encryption": "None", "version": "V1_0" }`; @@ -55,7 +55,7 @@ describe('shinkai_messag_handler isLocalMessage', () => { "signature": "c6d0115c0878fbf2279f98aab67c0e9cb1af63825f49dca48d6e4420eba0ceb973e00488ba0905c9afd09254f0dac48c468fdcb1d6c5ab5ca4c5dd70a440b903", "other": "" }, - "encryption": "DiffieHellmanChaChaPoly1305", + "encryption": "None", "version": "V1_0" }`; @@ -84,7 +84,7 @@ describe('shinkai_messag_handler isLocalMessage', () => { "signature": "c6d0115c0878fbf2279f98aab67c0e9cb1af63825f49dca48d6e4420eba0ceb973e00488ba0905c9afd09254f0dac48c468fdcb1d6c5ab5ca4c5dd70a440b903", "other": "" }, - "encryption": "DiffieHellmanChaChaPoly1305", + "encryption": "None", "version": "V1_0" }`; @@ -113,7 +113,7 @@ describe('shinkai_messag_handler isLocalMessage', () => { "signature": "c6d0115c0878fbf2279f98aab67c0e9cb1af63825f49dca48d6e4420eba0ceb973e00488ba0905c9afd09254f0dac48c468fdcb1d6c5ab5ca4c5dd70a440b903", "other": "" }, - "encryption": "DiffieHellmanChaChaPoly1305", + "encryption": "None", "version": "V1_0" }`; diff --git a/libs/shinkai-message-ts/src/utils/shinkai_message_handler.ts b/libs/shinkai-message-ts/src/utils/shinkai_message_handler.ts index 5f9db4580..4f68ae5f8 100644 --- a/libs/shinkai-message-ts/src/utils/shinkai_message_handler.ts +++ b/libs/shinkai-message-ts/src/utils/shinkai_message_handler.ts @@ -56,5 +56,6 @@ export const isLocalMessage = ( myProfile: string, ): boolean => { const messageNameWrapper = ShinkaiNameWrapper.from_shinkai_message_sender(message); - return messageNameWrapper.get_node_name === myNodeIdentity && messageNameWrapper.get_profile_name === myProfile; + return (messageNameWrapper.get_subidentity_type === 'None' || messageNameWrapper.get_subidentity_type === 'device') && + messageNameWrapper.get_node_name === myNodeIdentity && messageNameWrapper.get_profile_name === myProfile; }; diff --git a/libs/shinkai-message-ts/src/wasm/ShinkaiNameWrapper.test.ts b/libs/shinkai-message-ts/src/wasm/ShinkaiNameWrapper.test.ts index 8c2bd740b..1acd6bbf6 100644 --- a/libs/shinkai-message-ts/src/wasm/ShinkaiNameWrapper.test.ts +++ b/libs/shinkai-message-ts/src/wasm/ShinkaiNameWrapper.test.ts @@ -50,10 +50,31 @@ test("ShinkaiNameWrapper get_profile_name", () => { }); test("ShinkaiNameWrapper from_shinkai_message_sender", () => { - it('should fail when message is encrypted', () => { + it('should fail when message is first level encrypted', () => { const encryptedMessage = `{ "body": { "encrypted": { + "content": "encrypted:de9a22018a78cb1977d72936145576a4e040a590c5da6ac9f60f334c5fddd773b53ca11c5a97110e4352a694fa55632e9e07346e60a579171aea11fcf17a8e9666fe8f3bfddadafe5b2ecef5b8d7759979536e8ae848c1976a5057892836d0a5806fdaf4a30220217da2f4930914aea7b1f0f4ae65175ca9d24db4408294ca4b7347048a295ef5eeac1f3a60112953edf3f78bd02103fc9ae866cbb223385781218f0c021e41c79f529b7fd8748d8339db1cc0e03ae7d3b27b6147639cc01f44e594401bea76743ddefff47e737df61710c30fc7e5f38da306336cf668c198dfa2f90506" + } + }, + "external_metadata": { + "sender": "@@node1.shinkai/main", + "recipient": "@@node1.shinkai", + "scheduled_time": "2023-10-04T19:38:50.271Z", + "signature": "028810426c653e993deea94aa08b8fec14e82040ba73b09e533726eb769ea5de87ba095cc83cfe35035ca2db1ce996c963b7e7b12b1a28240706e4e0cbef6904", + "other": "" + }, + "encryption": "DiffieHellmanChaChaPoly1305", + "version": "V1_0" + }`; + const message = JSON.parse(encryptedMessage); + expect(ShinkaiNameWrapper.from_shinkai_message_sender(message)).toThrowError(); + }); + + it('should parse node_name, full_name, subidentity_name and subidentity_type when message is unepcrypted', () => { + const messageJson = `{ + "body": { + "unencrypted": { "message_data": { "unencrypted": { "message_raw_content": "hey!", @@ -76,31 +97,10 @@ test("ShinkaiNameWrapper from_shinkai_message_sender", () => { "signature": "c6d0115c0878fbf2279f98aab67c0e9cb1af63825f49dca48d6e4420eba0ceb973e00488ba0905c9afd09254f0dac48c468fdcb1d6c5ab5ca4c5dd70a440b903", "other": "" }, - "encryption": "DiffieHellmanChaChaPoly1305", - "version": "V1_0" - }`; - const message = JSON.parse(encryptedMessage); - expect(ShinkaiNameWrapper.from_shinkai_message_sender(message)).toThrowError(); - }); - - it('should fail when message is first level encrypted', () => { - const encryptedMessage = `{ - "body": { - "encrypted": { - "content": "encrypted:de9a22018a78cb1977d72936145576a4e040a590c5da6ac9f60f334c5fddd773b53ca11c5a97110e4352a694fa55632e9e07346e60a579171aea11fcf17a8e9666fe8f3bfddadafe5b2ecef5b8d7759979536e8ae848c1976a5057892836d0a5806fdaf4a30220217da2f4930914aea7b1f0f4ae65175ca9d24db4408294ca4b7347048a295ef5eeac1f3a60112953edf3f78bd02103fc9ae866cbb223385781218f0c021e41c79f529b7fd8748d8339db1cc0e03ae7d3b27b6147639cc01f44e594401bea76743ddefff47e737df61710c30fc7e5f38da306336cf668c198dfa2f90506" - } - }, - "external_metadata": { - "sender": "@@node1.shinkai/main", - "recipient": "@@node1.shinkai", - "scheduled_time": "2023-10-04T19:38:50.271Z", - "signature": "028810426c653e993deea94aa08b8fec14e82040ba73b09e533726eb769ea5de87ba095cc83cfe35035ca2db1ce996c963b7e7b12b1a28240706e4e0cbef6904", - "other": "" - }, - "encryption": "DiffieHellmanChaChaPoly1305", + "encryption": "None", "version": "V1_0" }`; - const message = JSON.parse(encryptedMessage); + const message = JSON.parse(messageJson); const messageNameWrapper = ShinkaiNameWrapper.from_shinkai_message_sender(message); expect(messageNameWrapper.get_node_name).toBe('@@node1.shinkai'); expect(messageNameWrapper.get_full_name).toBe('@@node1.shinkai/main/device/main_device'); From 1539c1095d43868a0d56ab20c42f7cff376317f7 Mon Sep 17 00:00:00 2001 From: Alfredo Gallardo Date: Wed, 4 Oct 2023 20:05:15 -0500 Subject: [PATCH 14/14] - fix: skipped nx cache --- .github/workflows/pr-ci-healchecks.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pr-ci-healchecks.yml b/.github/workflows/pr-ci-healchecks.yml index 3e90cd593..af8d8a727 100644 --- a/.github/workflows/pr-ci-healchecks.yml +++ b/.github/workflows/pr-ci-healchecks.yml @@ -39,7 +39,7 @@ jobs: - name: Install dependencies run: | npm cache verify - npm ci --no-audit + npm ci --no-audit --prefer-offline - name: Run NX target ${{ matrix.target }} on affected projects - run: npx nx affected -t ${{ matrix.target }} --parallel=3 --verbose + run: npx nx affected -t ${{ matrix.target }} --parallel=3 --skip-nx-cache --verbose