@ibgib/web-gib 0.0.1
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/.ibgibignore +30 -0
- package/.vscode/ibgib-snippets.code-snippets +309 -0
- package/.vscode/launch.json +25 -0
- package/.vscode/settings.json +68 -0
- package/.vscode/tasks.json +38 -0
- package/CHANGELOG.md +427 -0
- package/README.md +66 -0
- package/dist/agent-texts/common-agent-texts.d.mts +14 -0
- package/dist/agent-texts/common-agent-texts.d.mts.map +1 -0
- package/dist/agent-texts/common-agent-texts.mjs +51 -0
- package/dist/agent-texts/common-agent-texts.mjs.map +1 -0
- package/dist/agent-texts/primary-agent-texts.d.mts +16 -0
- package/dist/agent-texts/primary-agent-texts.d.mts.map +1 -0
- package/dist/agent-texts/primary-agent-texts.mjs +27 -0
- package/dist/agent-texts/primary-agent-texts.mjs.map +1 -0
- package/dist/agent-texts/project-agent-texts.d.mts +8 -0
- package/dist/agent-texts/project-agent-texts.d.mts.map +1 -0
- package/dist/agent-texts/project-agent-texts.mjs +29 -0
- package/dist/agent-texts/project-agent-texts.mjs.map +1 -0
- package/dist/agent-texts/project-child-text-agent-texts.d.mts +5 -0
- package/dist/agent-texts/project-child-text-agent-texts.d.mts.map +1 -0
- package/dist/agent-texts/project-child-text-agent-texts.mjs +26 -0
- package/dist/agent-texts/project-child-text-agent-texts.mjs.map +1 -0
- package/dist/agent-texts/projects-agent-texts.d.mts +4 -0
- package/dist/agent-texts/projects-agent-texts.d.mts.map +1 -0
- package/dist/agent-texts/projects-agent-texts.mjs +15 -0
- package/dist/agent-texts/projects-agent-texts.mjs.map +1 -0
- package/dist/agent-texts/raw-agent-texts.d.mts +4 -0
- package/dist/agent-texts/raw-agent-texts.d.mts.map +1 -0
- package/dist/agent-texts/raw-agent-texts.mjs +17 -0
- package/dist/agent-texts/raw-agent-texts.mjs.map +1 -0
- package/dist/agent-texts/text-editor-agent-texts.d.mts +6 -0
- package/dist/agent-texts/text-editor-agent-texts.d.mts.map +1 -0
- package/dist/agent-texts/text-editor-agent-texts.mjs +19 -0
- package/dist/agent-texts/text-editor-agent-texts.mjs.map +1 -0
- package/dist/api/api-constants.d.mts +9 -0
- package/dist/api/api-constants.d.mts.map +1 -0
- package/dist/api/api-constants.mjs +9 -0
- package/dist/api/api-constants.mjs.map +1 -0
- package/dist/api/api-index.d.mts +10 -0
- package/dist/api/api-index.d.mts.map +1 -0
- package/dist/api/api-index.mjs +121 -0
- package/dist/api/api-index.mjs.map +1 -0
- package/dist/api/api-types.d.mts +36 -0
- package/dist/api/api-types.d.mts.map +1 -0
- package/dist/api/api-types.mjs +2 -0
- package/dist/api/api-types.mjs.map +1 -0
- package/dist/api/commands/chat/chat-index.d.mts +3 -0
- package/dist/api/commands/chat/chat-index.d.mts.map +1 -0
- package/dist/api/commands/chat/chat-index.mjs +9 -0
- package/dist/api/commands/chat/chat-index.mjs.map +1 -0
- package/dist/api/commands/chat/get-context-info.d.mts +71 -0
- package/dist/api/commands/chat/get-context-info.d.mts.map +1 -0
- package/dist/api/commands/chat/get-context-info.mjs +130 -0
- package/dist/api/commands/chat/get-context-info.mjs.map +1 -0
- package/dist/api/commands/chat/hello-world.d.mts +63 -0
- package/dist/api/commands/chat/hello-world.d.mts.map +1 -0
- package/dist/api/commands/chat/hello-world.mjs +132 -0
- package/dist/api/commands/chat/hello-world.mjs.map +1 -0
- package/dist/api/commands/chat/tell-user.d.mts +57 -0
- package/dist/api/commands/chat/tell-user.d.mts.map +1 -0
- package/dist/api/commands/chat/tell-user.mjs +199 -0
- package/dist/api/commands/chat/tell-user.mjs.map +1 -0
- package/dist/api/commands/command-constants.d.mts +22 -0
- package/dist/api/commands/command-constants.d.mts.map +1 -0
- package/dist/api/commands/command-constants.mjs +17 -0
- package/dist/api/commands/command-constants.mjs.map +1 -0
- package/dist/api/commands/command-helpers.d.mts +47 -0
- package/dist/api/commands/command-helpers.d.mts.map +1 -0
- package/dist/api/commands/command-helpers.mjs +76 -0
- package/dist/api/commands/command-helpers.mjs.map +1 -0
- package/dist/api/commands/command-service-v1.d.mts +28 -0
- package/dist/api/commands/command-service-v1.d.mts.map +1 -0
- package/dist/api/commands/command-service-v1.mjs +122 -0
- package/dist/api/commands/command-service-v1.mjs.map +1 -0
- package/dist/api/commands/command-service.respec.d.mts +7 -0
- package/dist/api/commands/command-service.respec.d.mts.map +1 -0
- package/dist/api/commands/command-service.respec.mjs +66 -0
- package/dist/api/commands/command-service.respec.mjs.map +1 -0
- package/dist/api/commands/command-types.d.mts +48 -0
- package/dist/api/commands/command-types.d.mts.map +1 -0
- package/dist/api/commands/command-types.mjs +12 -0
- package/dist/api/commands/command-types.mjs.map +1 -0
- package/dist/api/commands/ibgib/get-ibgibs.d.mts +94 -0
- package/dist/api/commands/ibgib/get-ibgibs.d.mts.map +1 -0
- package/dist/api/commands/ibgib/get-ibgibs.mjs +219 -0
- package/dist/api/commands/ibgib/get-ibgibs.mjs.map +1 -0
- package/dist/api/commands/ibgib/ibgib-index.d.mts +3 -0
- package/dist/api/commands/ibgib/ibgib-index.d.mts.map +1 -0
- package/dist/api/commands/ibgib/ibgib-index.mjs +7 -0
- package/dist/api/commands/ibgib/ibgib-index.mjs.map +1 -0
- package/dist/api/commands/ibgib/mut8-ibgib.d.mts +135 -0
- package/dist/api/commands/ibgib/mut8-ibgib.d.mts.map +1 -0
- package/dist/api/commands/ibgib/mut8-ibgib.mjs +318 -0
- package/dist/api/commands/ibgib/mut8-ibgib.mjs.map +1 -0
- package/dist/api/commands/templates/api-function-info.template.d.mts +73 -0
- package/dist/api/commands/templates/api-function-info.template.d.mts.map +1 -0
- package/dist/api/commands/templates/api-function-info.template.mjs +161 -0
- package/dist/api/commands/templates/api-function-info.template.mjs.map +1 -0
- package/dist/api/commands/text/text-edit.d.mts +54 -0
- package/dist/api/commands/text/text-edit.d.mts.map +1 -0
- package/dist/api/commands/text/text-edit.mjs +170 -0
- package/dist/api/commands/text/text-edit.mjs.map +1 -0
- package/dist/api/commands/text/text-index.d.mts +3 -0
- package/dist/api/commands/text/text-index.d.mts.map +1 -0
- package/dist/api/commands/text/text-index.mjs +5 -0
- package/dist/api/commands/text/text-index.mjs.map +1 -0
- package/dist/api/commands/ui/ui-index.d.mts +3 -0
- package/dist/api/commands/ui/ui-index.d.mts.map +1 -0
- package/dist/api/commands/ui/ui-index.mjs +5 -0
- package/dist/api/commands/ui/ui-index.mjs.map +1 -0
- package/dist/api/commands/ui/update-css-variables.d.mts +48 -0
- package/dist/api/commands/ui/update-css-variables.d.mts.map +1 -0
- package/dist/api/commands/ui/update-css-variables.mjs +145 -0
- package/dist/api/commands/ui/update-css-variables.mjs.map +1 -0
- package/dist/api/function-infos.web.d.mts +15 -0
- package/dist/api/function-infos.web.d.mts.map +1 -0
- package/dist/api/function-infos.web.mjs +63 -0
- package/dist/api/function-infos.web.mjs.map +1 -0
- package/dist/assumptions.respec.d.mts +2 -0
- package/dist/assumptions.respec.d.mts.map +1 -0
- package/dist/assumptions.respec.mjs +41 -0
- package/dist/assumptions.respec.mjs.map +1 -0
- package/dist/common/project/project-constants.d.mts +38 -0
- package/dist/common/project/project-constants.d.mts.map +1 -0
- package/dist/common/project/project-constants.mjs +71 -0
- package/dist/common/project/project-constants.mjs.map +1 -0
- package/dist/common/project/project-helper.d.mts +127 -0
- package/dist/common/project/project-helper.d.mts.map +1 -0
- package/dist/common/project/project-helper.mjs +683 -0
- package/dist/common/project/project-helper.mjs.map +1 -0
- package/dist/common/project/project-types.d.mts +91 -0
- package/dist/common/project/project-types.d.mts.map +1 -0
- package/dist/common/project/project-types.mjs +31 -0
- package/dist/common/project/project-types.mjs.map +1 -0
- package/dist/common/prompt-functions.web.d.mts +90 -0
- package/dist/common/prompt-functions.web.d.mts.map +1 -0
- package/dist/common/prompt-functions.web.mjs +426 -0
- package/dist/common/prompt-functions.web.mjs.map +1 -0
- package/dist/common/settings/settings-constants.d.mts +33 -0
- package/dist/common/settings/settings-constants.d.mts.map +1 -0
- package/dist/common/settings/settings-constants.mjs +54 -0
- package/dist/common/settings/settings-constants.mjs.map +1 -0
- package/dist/common/settings/settings-helpers.d.mts +59 -0
- package/dist/common/settings/settings-helpers.d.mts.map +1 -0
- package/dist/common/settings/settings-helpers.mjs +253 -0
- package/dist/common/settings/settings-helpers.mjs.map +1 -0
- package/dist/common/settings/settings-types.d.mts +118 -0
- package/dist/common/settings/settings-types.d.mts.map +1 -0
- package/dist/common/settings/settings-types.mjs +13 -0
- package/dist/common/settings/settings-types.mjs.map +1 -0
- package/dist/constants.d.mts +34 -0
- package/dist/constants.d.mts.map +1 -0
- package/dist/constants.mjs +35 -0
- package/dist/constants.mjs.map +1 -0
- package/dist/foo.d.mts +2 -0
- package/dist/foo.d.mts.map +1 -0
- package/dist/foo.mjs +19 -0
- package/dist/foo.mjs.map +1 -0
- package/dist/helpers.d.mts +137 -0
- package/dist/helpers.d.mts.map +1 -0
- package/dist/helpers.mjs +514 -0
- package/dist/helpers.mjs.map +1 -0
- package/dist/helpers.web.d.mts +324 -0
- package/dist/helpers.web.d.mts.map +1 -0
- package/dist/helpers.web.mjs +1133 -0
- package/dist/helpers.web.mjs.map +1 -0
- package/dist/helpers.web.respec.d.mts +2 -0
- package/dist/helpers.web.respec.d.mts.map +1 -0
- package/dist/helpers.web.respec.mjs +12 -0
- package/dist/helpers.web.respec.mjs.map +1 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.d.mts.map +1 -0
- package/dist/index.mjs +3 -0
- package/dist/index.mjs.map +1 -0
- package/dist/respec-gib.node.d.mts +2 -0
- package/dist/respec-gib.node.d.mts.map +1 -0
- package/dist/respec-gib.node.mjs +211 -0
- package/dist/respec-gib.node.mjs.map +1 -0
- package/dist/spec-helper.node.respec.d.mts +13 -0
- package/dist/spec-helper.node.respec.d.mts.map +1 -0
- package/dist/spec-helper.node.respec.mjs +50 -0
- package/dist/spec-helper.node.respec.mjs.map +1 -0
- package/dist/storage/storage-helpers.web.d.mts +108 -0
- package/dist/storage/storage-helpers.web.d.mts.map +1 -0
- package/dist/storage/storage-helpers.web.mjs +757 -0
- package/dist/storage/storage-helpers.web.mjs.map +1 -0
- package/dist/storage/storage-types.web.d.mts +30 -0
- package/dist/storage/storage-types.web.d.mts.map +1 -0
- package/dist/storage/storage-types.web.mjs +2 -0
- package/dist/storage/storage-types.web.mjs.map +1 -0
- package/dist/types.web.d.mts +42 -0
- package/dist/types.web.d.mts.map +1 -0
- package/dist/types.web.mjs +2 -0
- package/dist/types.web.mjs.map +1 -0
- package/dist/ui/component/component-types.d.mts +225 -0
- package/dist/ui/component/component-types.d.mts.map +1 -0
- package/dist/ui/component/component-types.mjs +2 -0
- package/dist/ui/component/component-types.mjs.map +1 -0
- package/dist/ui/component/ibgib-component-service.d.mts +70 -0
- package/dist/ui/component/ibgib-component-service.d.mts.map +1 -0
- package/dist/ui/component/ibgib-component-service.mjs +201 -0
- package/dist/ui/component/ibgib-component-service.mjs.map +1 -0
- package/dist/ui/component/ibgib-dynamic-component-bases.d.mts +338 -0
- package/dist/ui/component/ibgib-dynamic-component-bases.d.mts.map +1 -0
- package/dist/ui/component/ibgib-dynamic-component-bases.mjs +1304 -0
- package/dist/ui/component/ibgib-dynamic-component-bases.mjs.map +1 -0
- package/dist/ui/ui-constants.d.mts +12 -0
- package/dist/ui/ui-constants.d.mts.map +1 -0
- package/dist/ui/ui-constants.mjs +93 -0
- package/dist/ui/ui-constants.mjs.map +1 -0
- package/dist/ui/ui-helpers.d.mts +42 -0
- package/dist/ui/ui-helpers.d.mts.map +1 -0
- package/dist/ui/ui-helpers.mjs +198 -0
- package/dist/ui/ui-helpers.mjs.map +1 -0
- package/dist/ui/ui-types.d.mts +13 -0
- package/dist/ui/ui-types.d.mts.map +1 -0
- package/dist/ui/ui-types.mjs +2 -0
- package/dist/ui/ui-types.mjs.map +1 -0
- package/dist/witness/agent/agent-constants.d.mts +97 -0
- package/dist/witness/agent/agent-constants.d.mts.map +1 -0
- package/dist/witness/agent/agent-constants.mjs +98 -0
- package/dist/witness/agent/agent-constants.mjs.map +1 -0
- package/dist/witness/agent/agent-helpers.d.mts +106 -0
- package/dist/witness/agent/agent-helpers.d.mts.map +1 -0
- package/dist/witness/agent/agent-helpers.mjs +601 -0
- package/dist/witness/agent/agent-helpers.mjs.map +1 -0
- package/dist/witness/agent/agent-one-file.app.d.mts +2 -0
- package/dist/witness/agent/agent-one-file.app.d.mts.map +1 -0
- package/dist/witness/agent/agent-one-file.app.mjs +8 -0
- package/dist/witness/agent/agent-one-file.app.mjs.map +1 -0
- package/dist/witness/agent/agent-one-file.d.mts +478 -0
- package/dist/witness/agent/agent-one-file.d.mts.map +1 -0
- package/dist/witness/agent/agent-one-file.mjs +1462 -0
- package/dist/witness/agent/agent-one-file.mjs.map +1 -0
- package/dist/witness/agent/agent-types.d.mts +83 -0
- package/dist/witness/agent/agent-types.d.mts.map +1 -0
- package/dist/witness/agent/agent-types.mjs +2 -0
- package/dist/witness/agent/agent-types.mjs.map +1 -0
- package/dist/witness/agent/agents-service-v1.d.mts +99 -0
- package/dist/witness/agent/agents-service-v1.d.mts.map +1 -0
- package/dist/witness/agent/agents-service-v1.mjs +453 -0
- package/dist/witness/agent/agents-service-v1.mjs.map +1 -0
- package/dist/witness/agent/function-info/function-info-one-file.d.mts +192 -0
- package/dist/witness/agent/function-info/function-info-one-file.d.mts.map +1 -0
- package/dist/witness/agent/function-info/function-info-one-file.mjs +192 -0
- package/dist/witness/agent/function-info/function-info-one-file.mjs.map +1 -0
- package/dist/witness/agent/gemini/agent-witness-gemini-v1.d.mts +51 -0
- package/dist/witness/agent/gemini/agent-witness-gemini-v1.d.mts.map +1 -0
- package/dist/witness/agent/gemini/agent-witness-gemini-v1.mjs +928 -0
- package/dist/witness/agent/gemini/agent-witness-gemini-v1.mjs.map +1 -0
- package/dist/witness/agent/gemini/gemini-agent-factory.d.mts +27 -0
- package/dist/witness/agent/gemini/gemini-agent-factory.d.mts.map +1 -0
- package/dist/witness/agent/gemini/gemini-agent-factory.mjs +144 -0
- package/dist/witness/agent/gemini/gemini-agent-factory.mjs.map +1 -0
- package/dist/witness/agent/gemini/gemini-constants.d.mts +36 -0
- package/dist/witness/agent/gemini/gemini-constants.d.mts.map +1 -0
- package/dist/witness/agent/gemini/gemini-constants.mjs +47 -0
- package/dist/witness/agent/gemini/gemini-constants.mjs.map +1 -0
- package/dist/witness/agent/gemini/gemini-helpers.d.mts +58 -0
- package/dist/witness/agent/gemini/gemini-helpers.d.mts.map +1 -0
- package/dist/witness/agent/gemini/gemini-helpers.mjs +210 -0
- package/dist/witness/agent/gemini/gemini-helpers.mjs.map +1 -0
- package/dist/witness/agent/gemini/gemini-types.d.mts +82 -0
- package/dist/witness/agent/gemini/gemini-types.d.mts.map +1 -0
- package/dist/witness/agent/gemini/gemini-types.mjs +3 -0
- package/dist/witness/agent/gemini/gemini-types.mjs.map +1 -0
- package/dist/witness/live-proxy-ibgib/live-proxy-ibgib-one-file.d.mts +136 -0
- package/dist/witness/live-proxy-ibgib/live-proxy-ibgib-one-file.d.mts.map +1 -0
- package/dist/witness/live-proxy-ibgib/live-proxy-ibgib-one-file.mjs +334 -0
- package/dist/witness/live-proxy-ibgib/live-proxy-ibgib-one-file.mjs.map +1 -0
- package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace-helper.d.mts +35 -0
- package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace-helper.d.mts.map +1 -0
- package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace-helper.mjs +267 -0
- package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace-helper.mjs.map +1 -0
- package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace.d.mts +134 -0
- package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace.d.mts.map +1 -0
- package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace.mjs +389 -0
- package/dist/witness/space/metaspace/metaspace-webspace/metaspace-webspace.mjs.map +1 -0
- package/dist/witness/space/web-filesystem-space/web-filesystem-space-constants.d.mts +2 -0
- package/dist/witness/space/web-filesystem-space/web-filesystem-space-constants.d.mts.map +1 -0
- package/dist/witness/space/web-filesystem-space/web-filesystem-space-constants.mjs +2 -0
- package/dist/witness/space/web-filesystem-space/web-filesystem-space-constants.mjs.map +1 -0
- package/dist/witness/space/web-filesystem-space/web-filesystem-space-helper.d.mts +104 -0
- package/dist/witness/space/web-filesystem-space/web-filesystem-space-helper.d.mts.map +1 -0
- package/dist/witness/space/web-filesystem-space/web-filesystem-space-helper.mjs +457 -0
- package/dist/witness/space/web-filesystem-space/web-filesystem-space-helper.mjs.map +1 -0
- package/dist/witness/space/web-filesystem-space/web-filesystem-space-types.d.mts +93 -0
- package/dist/witness/space/web-filesystem-space/web-filesystem-space-types.d.mts.map +1 -0
- package/dist/witness/space/web-filesystem-space/web-filesystem-space-types.mjs +98 -0
- package/dist/witness/space/web-filesystem-space/web-filesystem-space-types.mjs.map +1 -0
- package/dist/witness/space/web-filesystem-space/web-filesystem-space-v1.d.mts +73 -0
- package/dist/witness/space/web-filesystem-space/web-filesystem-space-v1.d.mts.map +1 -0
- package/dist/witness/space/web-filesystem-space/web-filesystem-space-v1.mjs +650 -0
- package/dist/witness/space/web-filesystem-space/web-filesystem-space-v1.mjs.map +1 -0
- package/generate-version-file.js +29 -0
- package/package.json +60 -0
- package/src/agent-texts/common-agent-texts.mts +61 -0
- package/src/agent-texts/primary-agent-texts.mts +32 -0
- package/src/agent-texts/project-agent-texts.mts +29 -0
- package/src/agent-texts/project-child-text-agent-texts.mts +30 -0
- package/src/agent-texts/projects-agent-texts.mts +17 -0
- package/src/agent-texts/raw-agent-texts.mts +18 -0
- package/src/agent-texts/text-editor-agent-texts.mts +20 -0
- package/src/api/api-constants.mts +8 -0
- package/src/api/api-index.mts +110 -0
- package/src/api/api-types.mts +36 -0
- package/src/api/commands/chat/chat-index.mts +10 -0
- package/src/api/commands/chat/get-context-info.mts +196 -0
- package/src/api/commands/chat/hello-world.mts +183 -0
- package/src/api/commands/chat/tell-user.mts +241 -0
- package/src/api/commands/command-constants.mts +17 -0
- package/src/api/commands/command-helpers.mts +105 -0
- package/src/api/commands/command-service-v1.mts +136 -0
- package/src/api/commands/command-service.respec.mts +72 -0
- package/src/api/commands/command-types.mts +71 -0
- package/src/api/commands/ibgib/get-ibgibs.mts +269 -0
- package/src/api/commands/ibgib/ibgib-index.mts +8 -0
- package/src/api/commands/ibgib/mut8-ibgib.mts +418 -0
- package/src/api/commands/templates/api-function-info.template.mts +212 -0
- package/src/api/commands/text/text-edit.mts +217 -0
- package/src/api/commands/text/text-index.mts +6 -0
- package/src/api/commands/ui/ui-index.mts +6 -0
- package/src/api/commands/ui/update-css-variables.mts +187 -0
- package/src/api/function-infos.web.mts +66 -0
- package/src/assets/fullscreen-dialog.html +18 -0
- package/src/assumptions.respec.mts +51 -0
- package/src/common/project/project-constants.mts +83 -0
- package/src/common/project/project-helper.mts +730 -0
- package/src/common/project/project-types.mts +121 -0
- package/src/common/prompt-functions.web.mts +447 -0
- package/src/common/settings/settings-constants.mts +72 -0
- package/src/common/settings/settings-helpers.mts +280 -0
- package/src/common/settings/settings-types.mts +137 -0
- package/src/constants.mts +39 -0
- package/src/foo.mts +13 -0
- package/src/helpers.mts +574 -0
- package/src/helpers.web.mts +1277 -0
- package/src/helpers.web.respec.mts +16 -0
- package/src/index.mts +3 -0
- package/src/respec-gib.node.mts +199 -0
- package/src/spec-helper.node.respec.mts +50 -0
- package/src/storage/storage-helpers.web.mts +728 -0
- package/src/storage/storage-types.web.mts +29 -0
- package/src/types.web.mts +42 -0
- package/src/ui/component/component-types.mts +241 -0
- package/src/ui/component/ibgib-component-service.mts +201 -0
- package/src/ui/component/ibgib-dynamic-component-bases.mts +1369 -0
- package/src/ui/ui-constants.mts +101 -0
- package/src/ui/ui-helpers.mts +222 -0
- package/src/ui/ui-types.mts +11 -0
- package/src/witness/agent/agent-constants.mts +122 -0
- package/src/witness/agent/agent-helpers.mts +681 -0
- package/src/witness/agent/agent-one-file.app.mts +8 -0
- package/src/witness/agent/agent-one-file.mts +1665 -0
- package/src/witness/agent/agent-types.mts +92 -0
- package/src/witness/agent/agents-service-v1.mts +482 -0
- package/src/witness/agent/function-info/function-info-one-file.mts +362 -0
- package/src/witness/agent/gemini/agent-witness-gemini-v1.mts +910 -0
- package/src/witness/agent/gemini/gemini-agent-factory.mts +135 -0
- package/src/witness/agent/gemini/gemini-constants.mts +79 -0
- package/src/witness/agent/gemini/gemini-helpers.mts +216 -0
- package/src/witness/agent/gemini/gemini-types.mts +88 -0
- package/src/witness/live-proxy-ibgib/live-proxy-ibgib-one-file.mts +321 -0
- package/src/witness/space/metaspace/metaspace-webspace/metaspace-webspace-helper.mts +290 -0
- package/src/witness/space/metaspace/metaspace-webspace/metaspace-webspace.mts +407 -0
- package/src/witness/space/web-filesystem-space/web-filesystem-space-constants.mts +1 -0
- package/src/witness/space/web-filesystem-space/web-filesystem-space-helper.mts +491 -0
- package/src/witness/space/web-filesystem-space/web-filesystem-space-types.mts +172 -0
- package/src/witness/space/web-filesystem-space/web-filesystem-space-v1.mts +670 -0
- package/tsconfig.json +17 -0
- package/tsconfig.test.json +10 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
// import { extractErrorMsg, pretty, } from '@ibgib/helper-gib/dist/helpers/utils-helper.mjs';
|
|
2
|
+
import { IbGib_V1 } from '@ibgib/ts-gib/dist/V1/types.mjs';
|
|
3
|
+
import { IbGibSpaceAny } from '@ibgib/core-gib/dist/witness/space/space-base-v1.mjs';
|
|
4
|
+
import { MetaspaceService } from '@ibgib/core-gib/dist/witness/space/metaspace/metaspace-types.mjs';
|
|
5
|
+
|
|
6
|
+
// import { GLOBAL_LOG_A_LOT } from '../../constants.mjs';
|
|
7
|
+
import { APIFunctionInfo } from '../../api/api-types.mjs';
|
|
8
|
+
import type { AgentWitness_V1 } from './agent-one-file.mjs';
|
|
9
|
+
import {
|
|
10
|
+
AgentWitnessAny, AgentWitnessData_V1, AgentWitnessRel8ns_V1,
|
|
11
|
+
} from './agent-one-file.mjs';
|
|
12
|
+
import { GeminiModel } from './gemini/gemini-constants.mjs';
|
|
13
|
+
|
|
14
|
+
export type AgentModel =
|
|
15
|
+
| GeminiModel;
|
|
16
|
+
/**
|
|
17
|
+
* API discriminator of the underlying model.
|
|
18
|
+
*
|
|
19
|
+
* @see {@link AgentWitness_V1}
|
|
20
|
+
* @see {@link AgentWitnessData_V1.api}
|
|
21
|
+
*/
|
|
22
|
+
export type AgentAPI = 'gemini';
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* shape of passed in arg of {@link createNewAgent}.
|
|
26
|
+
*
|
|
27
|
+
* ATOW (01/2024)
|
|
28
|
+
*/
|
|
29
|
+
export interface CreateNewAgentArg {
|
|
30
|
+
/**
|
|
31
|
+
* metaspace singleton
|
|
32
|
+
*/
|
|
33
|
+
metaspace: MetaspaceService;
|
|
34
|
+
/**
|
|
35
|
+
* optional space in which to save the agent itself (and dependency ibgibs).
|
|
36
|
+
* This is often (always?) different than
|
|
37
|
+
* @default superSpace is the metaspace's default local user space
|
|
38
|
+
*/
|
|
39
|
+
superSpace?: IbGibSpaceAny;
|
|
40
|
+
/**
|
|
41
|
+
* optional name of new agent. Does not have to be unique, but that's always
|
|
42
|
+
* nice. if not provided, a random one will be created.
|
|
43
|
+
*/
|
|
44
|
+
name?: string;
|
|
45
|
+
api: AgentAPI;
|
|
46
|
+
model: AgentModel;
|
|
47
|
+
/**
|
|
48
|
+
* what functions are available to the agent. if no functions are available
|
|
49
|
+
* to the agent, then provide an empty array.
|
|
50
|
+
* @see {@link AgentWitness_V1.getAvailableFunctions}
|
|
51
|
+
*/
|
|
52
|
+
availableFunctions: APIFunctionInfo[];
|
|
53
|
+
initialSystemText: string;
|
|
54
|
+
/**
|
|
55
|
+
* initial text from the user to the agent.
|
|
56
|
+
*/
|
|
57
|
+
initialChatText: string;
|
|
58
|
+
/**
|
|
59
|
+
* @see {@link AgentWitness_V1.fnGetAPIKey}
|
|
60
|
+
*/
|
|
61
|
+
fnGetAPIKey: () => Promise<string>;
|
|
62
|
+
/**
|
|
63
|
+
* if true, will tag the agent with the agents tag in the {@link metaspace}
|
|
64
|
+
* and {@link superSpace}.
|
|
65
|
+
*/
|
|
66
|
+
addToAgentsTag?: boolean;
|
|
67
|
+
/**
|
|
68
|
+
* will be used as the SpecialIbGibType
|
|
69
|
+
*/
|
|
70
|
+
type: string;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/**
|
|
74
|
+
* shape of return value of {@link createNewAgent}.
|
|
75
|
+
*
|
|
76
|
+
* ATOW (01/2025)
|
|
77
|
+
*/
|
|
78
|
+
export type CreateNewAgentResult = AgentWitnessAny;
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* factory to create concrete agents that correspond to a given {@link arg}.
|
|
82
|
+
*
|
|
83
|
+
* Specifically this is intended to look at the {@link CreateNewAgentArg.api}
|
|
84
|
+
*/
|
|
85
|
+
export interface CreateConcreteAgentWitnessFactory {
|
|
86
|
+
createInitialData(superSpace: IbGibSpaceAny): Promise<AgentWitnessData_V1>;
|
|
87
|
+
createInitialRel8ns(): Promise<AgentWitnessRel8ns_V1 | undefined>;
|
|
88
|
+
createWitness(): Promise<AgentWitnessAny>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export type AgentDtoToWitnessFunction =
|
|
92
|
+
(dto: IbGib_V1) => Promise<{ applies: boolean, agent?: AgentWitnessAny }>;
|
|
@@ -0,0 +1,482 @@
|
|
|
1
|
+
import { extractErrorMsg, pretty } from "@ibgib/helper-gib/dist/helpers/utils-helper.mjs";
|
|
2
|
+
import { IbGib_V1 } from "@ibgib/ts-gib/dist/V1/types.mjs";
|
|
3
|
+
import { IbGibAddr } from "@ibgib/ts-gib/dist/types.mjs";
|
|
4
|
+
import { getIbAndGib } from "@ibgib/ts-gib/dist/helper.mjs";
|
|
5
|
+
import { Factory_V1 } from "@ibgib/ts-gib/dist/V1/factory.mjs";
|
|
6
|
+
import { rel8ToTag } from "@ibgib/core-gib/dist/common/tag/tag-helper.mjs";
|
|
7
|
+
import { SpaceId } from "@ibgib/core-gib/dist/witness/space/space-types.mjs";
|
|
8
|
+
import { MetaspaceService } from "@ibgib/core-gib/dist/witness/space/metaspace/metaspace-types.mjs";
|
|
9
|
+
import { SpecialIbGibType } from "@ibgib/core-gib/dist/common/other/other-types.mjs";
|
|
10
|
+
import { IbGibSpaceAny } from "@ibgib/core-gib/dist/witness/space/space-base-v1.mjs";
|
|
11
|
+
import { toDto } from "@ibgib/core-gib/dist/common/other/ibgib-helper.mjs";
|
|
12
|
+
import { updateSpecialIndex } from "@ibgib/core-gib/dist/timeline/timeline-api.mjs";
|
|
13
|
+
|
|
14
|
+
import { GLOBAL_LOG_A_LOT, HARDCODED_PROMPT_TAG_TEXT } from "../../constants.mjs";
|
|
15
|
+
import { getGlobalMetaspace_waitIfNeeded } from "../../helpers.web.mjs";
|
|
16
|
+
import { getAgents, getConcreteAgentFactory, getTag_Agents } from "./agent-helpers.mjs";
|
|
17
|
+
import { AddTextInfo, AgentWitnessAny, AgentWitnessData_V1, AgentWitnessIbGib_V1, getAgentIb, parseAgentIb, taggifyForPrompt } from "./agent-one-file.mjs";
|
|
18
|
+
import { AgentDtoToWitnessFunction, CreateNewAgentArg, CreateNewAgentResult } from "./agent-types.mjs";
|
|
19
|
+
import { AGENT_ATOM, AGENT_REL8N_NAME } from "./agent-constants.mjs";
|
|
20
|
+
|
|
21
|
+
const logalot = GLOBAL_LOG_A_LOT;
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* I'm having an issue with agents being out of date. I don't want to have to
|
|
26
|
+
* update the agent to the latest which would require calling getLatest
|
|
27
|
+
* (relatively expensive).
|
|
28
|
+
*
|
|
29
|
+
* but I am having an issue where I update an agent, but before I can update the
|
|
30
|
+
* spcial ibgib index, it is being loaded again. So I am trying a hack to have a
|
|
31
|
+
* simple in-memory latest hack.
|
|
32
|
+
*
|
|
33
|
+
* So the idea is that we will consider agents to be singleton-like, i.e., only
|
|
34
|
+
* one local timeline allowed.
|
|
35
|
+
*/
|
|
36
|
+
export class AgentsService_V1 {
|
|
37
|
+
private lc: string = `[${AgentsService_V1.name}]`;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* dtos of latest agents
|
|
41
|
+
*/
|
|
42
|
+
private latestAgents: Map<string, AgentWitnessAny> = new Map();
|
|
43
|
+
|
|
44
|
+
private factoryFns: { [classname: string]: AgentDtoToWitnessFunction } = {};
|
|
45
|
+
|
|
46
|
+
constructor() {
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async getAgentById(opts: {
|
|
50
|
+
agentId: string,
|
|
51
|
+
agentType: string,
|
|
52
|
+
spaceId?: SpaceId,
|
|
53
|
+
}): Promise<AgentWitnessAny | undefined> {
|
|
54
|
+
const lc = `${this.lc}[${this.getAgentById.name}]`;
|
|
55
|
+
try {
|
|
56
|
+
const {
|
|
57
|
+
agentId,
|
|
58
|
+
agentType,
|
|
59
|
+
spaceId,
|
|
60
|
+
} = opts;
|
|
61
|
+
if (logalot) { console.log(`${lc} starting... (I: 0c4214b4614a43bd2825978e54aee325)`); }
|
|
62
|
+
let agent = this.latestAgents.get(agentId);
|
|
63
|
+
if (!agent) {
|
|
64
|
+
const metaspace = await getGlobalMetaspace_waitIfNeeded();
|
|
65
|
+
const agents = await getAgents({ metaspace, type: agentType, spaceId });
|
|
66
|
+
agent = agents.find(x => x.data!.uuid === agentId);
|
|
67
|
+
}
|
|
68
|
+
if (!agent) { console.warn(`${lc} couldn't find any agent by id. opts: ${pretty(opts)} (W: 70cf51ecbe68dfdcfe1e9995a7468f25)`); }
|
|
69
|
+
return agent;
|
|
70
|
+
} catch (error) {
|
|
71
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
72
|
+
throw error;
|
|
73
|
+
} finally {
|
|
74
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/**
|
|
79
|
+
* SHOULD NOT NEED THIS... USE A GD PROXY.
|
|
80
|
+
*
|
|
81
|
+
* if the incoming {@link agent} is the most recent, then this will save
|
|
82
|
+
* this agent as the latest.
|
|
83
|
+
*
|
|
84
|
+
* if the incoming {@link agent} is equal, then nothing happens.
|
|
85
|
+
*
|
|
86
|
+
* if the incoming {@link agent} is older than the known latest agent, then
|
|
87
|
+
* the incoming {@link agent} will load the most recent agent's dto unless {@link throwIfNewerFound} is true.
|
|
88
|
+
*/
|
|
89
|
+
async updateOrSetLatestAgent({
|
|
90
|
+
agent,
|
|
91
|
+
throwIfNewerFound,
|
|
92
|
+
}: {
|
|
93
|
+
agent: AgentWitnessAny,
|
|
94
|
+
throwIfNewerFound?: boolean,
|
|
95
|
+
}): Promise<void> {
|
|
96
|
+
const lc = `${this.lc}[${this.updateOrSetLatestAgent.name}]`;
|
|
97
|
+
try {
|
|
98
|
+
if (logalot) { console.log(`${lc} starting... (I: 9bb74f19b989fc0ee969cb4c2c2aa525)`); }
|
|
99
|
+
if (!agent.data) { throw new Error(`invalid agent. data falsy. agent.ib: ${agent.ib} (E: 7356db7395cb0c5664d13437dd62c425)`); }
|
|
100
|
+
if (!agent.data.uuid) { throw new Error(`invalid agent. data.uuid falsy. agent.ib: ${agent.ib} (E: 48afcd6658154bee1138fca31cbfbf25)`); }
|
|
101
|
+
|
|
102
|
+
const existing = await this.getLatestAgent({ id: agent.data.uuid });
|
|
103
|
+
if (existing) {
|
|
104
|
+
// check existing against the one we're trying to set.
|
|
105
|
+
if (!existing.data) { throw new Error(`(UNEXPECTED) existing.data falsy? should have thrown on previous set function call? (E: f3cbae9922ea9849ada25db2eea40825)`); }
|
|
106
|
+
if (existing.data.n! === agent.data.n!) {
|
|
107
|
+
if (existing.gib === agent.gib) {
|
|
108
|
+
// already have this version
|
|
109
|
+
return; /* <<<< returns early */
|
|
110
|
+
} else {
|
|
111
|
+
console.warn(`existing.data.n === agent.data.n but gibs are different. We have a branched timeline. just logging this error, need to figure out wth is going on here. we should not have this with the timeline being locked. The only thing I can think of is if the ibgib is updated very quickly, but even then, the n should be incremented. still the approach is valid. anyway, we're going ahead and taking the newer agent.\nexisting: ${pretty(toDto({ ibGib: existing }))}\nnew: ${pretty(toDto({ ibGib: agent }))} (E: 5e079b566ff3533acdb2d01359f08625)`);
|
|
112
|
+
await existing.loadIbGibDto(agent.toIbGibDto())
|
|
113
|
+
this.latestAgents.set(agent.data.uuid, agent);
|
|
114
|
+
return; /* <<<< returns early */
|
|
115
|
+
}
|
|
116
|
+
} else if (existing.data.n! > agent.data.n!) {
|
|
117
|
+
const msg = `existing.data.n > agent.data.n, i.e., the one we already have is newer. So why was the caller trying to set to the older agent thinking it was the most recent? Probably have a branched timeline.`;
|
|
118
|
+
if (throwIfNewerFound) {
|
|
119
|
+
throw new Error(`${lc} ${msg} (E: bb2cc3ce8cfa88b80fb62149b0e70225)`);
|
|
120
|
+
} else {
|
|
121
|
+
console.warn(`${lc} ${msg} (W: caaf66deb4e6fd8e2eb9261685dc0325)`);
|
|
122
|
+
}
|
|
123
|
+
return; /* <<<< returns early */
|
|
124
|
+
} else {
|
|
125
|
+
// happy path, the new one is newer than the existing one
|
|
126
|
+
await existing.loadIbGibDto(agent.toIbGibDto())
|
|
127
|
+
this.latestAgents.set(agent.data.uuid, agent);
|
|
128
|
+
return; /* <<<< returns early */
|
|
129
|
+
}
|
|
130
|
+
} else {
|
|
131
|
+
this.latestAgents.set(agent.data.uuid, agent);
|
|
132
|
+
return; /* <<<< returns early */
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
} catch (error) {
|
|
136
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
137
|
+
throw error;
|
|
138
|
+
} finally {
|
|
139
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* gets the most recent agent witness corresponding to the given {@link id},
|
|
145
|
+
* if found. If not found, then returns undefined.
|
|
146
|
+
*
|
|
147
|
+
* ## atow 04/2025 - implementation note
|
|
148
|
+
*
|
|
149
|
+
* right now this executes sync but is promise-based, because in the future
|
|
150
|
+
* this has a decent chance of becoming truly promise-based.
|
|
151
|
+
*/
|
|
152
|
+
getLatestAgent({
|
|
153
|
+
id,
|
|
154
|
+
}: {
|
|
155
|
+
id: string,
|
|
156
|
+
}): Promise<AgentWitnessAny | undefined> {
|
|
157
|
+
const lc = `${this.lc}[${this.getLatestAgent.name}]`;
|
|
158
|
+
try {
|
|
159
|
+
if (logalot) { console.log(`${lc} starting... (I: 8e85b55057760b712a913a92e88ead25)`); }
|
|
160
|
+
return Promise.resolve(this.latestAgents.get(id));
|
|
161
|
+
// const agents = this.latestAgents.filter(x => x.data!.uuid === id);
|
|
162
|
+
// if (agents.length === 1) {
|
|
163
|
+
// return agents.at(0)!;
|
|
164
|
+
// } else if (agents.length === 0) {
|
|
165
|
+
// return undefined;
|
|
166
|
+
// } else {
|
|
167
|
+
// throw new Error(`(UNEXPECTED) more than one agent with the same agent.data.uuid (${id})? (E: a4e3bc9053523e0eb4ec5514e1825825)`);
|
|
168
|
+
// }
|
|
169
|
+
} catch (error) {
|
|
170
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
171
|
+
throw error;
|
|
172
|
+
} finally {
|
|
173
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
registerFactory({
|
|
178
|
+
classname,
|
|
179
|
+
fnDtoToAgentWitness,
|
|
180
|
+
}: {
|
|
181
|
+
classname: string,
|
|
182
|
+
fnDtoToAgentWitness: AgentDtoToWitnessFunction,
|
|
183
|
+
}): void {
|
|
184
|
+
this.factoryFns[classname] = fnDtoToAgentWitness;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
async getAgentWitnessFromDto({
|
|
188
|
+
dto,
|
|
189
|
+
classname,
|
|
190
|
+
}: {
|
|
191
|
+
dto: IbGib_V1,
|
|
192
|
+
/**
|
|
193
|
+
* if provided, wills pecifically attempt to use the factory function
|
|
194
|
+
* registered for this classname. otherwise, will attempt to derive from
|
|
195
|
+
* {@link dto}.
|
|
196
|
+
*/
|
|
197
|
+
classname?: string,
|
|
198
|
+
}): Promise<AgentWitnessAny | undefined> {
|
|
199
|
+
const lc = `${this.lc}[${this.getAgentWitnessFromDto.name}]`;
|
|
200
|
+
try {
|
|
201
|
+
if (logalot) { console.log(`${lc} starting... (I: 718837d4ee3d590177f3425b99106225)`); }
|
|
202
|
+
if (!dto.data) { throw new Error(`dto.data falsy (E: fad89dd4c787b687a657c13968946925)`); }
|
|
203
|
+
|
|
204
|
+
let agent: AgentWitnessAny | undefined = undefined;
|
|
205
|
+
classname ??= (dto.data as AgentWitnessData_V1).classname;
|
|
206
|
+
if (classname) {
|
|
207
|
+
const fn = this.factoryFns[classname];
|
|
208
|
+
const res = await fn(dto);
|
|
209
|
+
if (res.applies) {
|
|
210
|
+
if (!res.agent) { throw new Error(`(UNEXPECTED) factory function for agent dto applies: true, but the resulting agent is undefined? (E: b13cdf0f3d9c50f1fa419f2c409ebf25)`); }
|
|
211
|
+
agent = res.agent;
|
|
212
|
+
} else {
|
|
213
|
+
throw new Error(`classname (${classname}) factory function found and attempted, but result says applied: false. (E: 751a2502c9a7e2d61c76c8ae2f7fb125)`);
|
|
214
|
+
}
|
|
215
|
+
} else {
|
|
216
|
+
// not found, try to brute force
|
|
217
|
+
const fnClassnames = Object.keys(this.factoryFns);
|
|
218
|
+
for (const fnClassname of fnClassnames) {
|
|
219
|
+
const fn = this.factoryFns[fnClassname];
|
|
220
|
+
const res = await fn(dto);
|
|
221
|
+
if (res.applies) {
|
|
222
|
+
if (!res.agent) { throw new Error(`(UNEXPECTED) factory function for agent dto applies: true, but the resulting agent is undefined? (E: 60e97c083a668baf11efcd6adf6a3525)`); }
|
|
223
|
+
agent = res.agent;
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
return agent;
|
|
229
|
+
} catch (error) {
|
|
230
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
231
|
+
throw error;
|
|
232
|
+
} finally {
|
|
233
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
/**
|
|
238
|
+
* Retrieves an agent instance by its ibGib address.
|
|
239
|
+
* Checks the in-memory cache first. If not found, retrieves the agent ibGib
|
|
240
|
+
* from the specified space, converts the DTO to a witness, and caches it.
|
|
241
|
+
*/
|
|
242
|
+
async getAgentByAddr({
|
|
243
|
+
agentAddr,
|
|
244
|
+
spaceId,
|
|
245
|
+
metaspace, // Assuming metaspace might be needed here
|
|
246
|
+
}: {
|
|
247
|
+
agentAddr: IbGibAddr,
|
|
248
|
+
spaceId?: SpaceId,
|
|
249
|
+
metaspace?: MetaspaceService,
|
|
250
|
+
}): Promise<AgentWitnessAny | undefined> {
|
|
251
|
+
const lc = `${this.lc}[${this.getAgentByAddr.name}]`;
|
|
252
|
+
try {
|
|
253
|
+
if (logalot) { console.log(`${lc} starting... (I: 42dfecbe6d6b5a3a7d392af5a66cc625)`); }
|
|
254
|
+
|
|
255
|
+
if (!agentAddr) { throw new Error(`${lc} agentAddr is required. (E: 389351659a2e08fa179ceede16925a25)`); }
|
|
256
|
+
|
|
257
|
+
// first check to see if we have it in the agents service already
|
|
258
|
+
const { ib: agentIb } = getIbAndGib({ ibGibAddr: agentAddr });
|
|
259
|
+
let { uuid: agentId, type: agentType } = parseAgentIb({ ib: agentIb });
|
|
260
|
+
|
|
261
|
+
if (!agentId) {
|
|
262
|
+
debugger; // error agent ib didn't have uuid?
|
|
263
|
+
throw new Error(`(UNEXPECTED) agentAddr doesn't have uuid in the ib? agentAddr: ${agentAddr} (E: fedcacffed98fdc78b1e80e45c413925)`);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
let resAgent = await this.getAgentById({
|
|
267
|
+
agentId,
|
|
268
|
+
agentType,
|
|
269
|
+
});
|
|
270
|
+
|
|
271
|
+
if (resAgent) {
|
|
272
|
+
if (logalot) { console.log(`${lc} agent found already in agents svc so didn't need to go get it from the space. (I: ec6abaf3badd8e301d79a7476845bc25)`); }
|
|
273
|
+
return resAgent; /* <<<< returns early */
|
|
274
|
+
}
|
|
275
|
+
|
|
276
|
+
// we do NOT yet have it in the agents svc. so get the ibgib,
|
|
277
|
+
// convert it to a witness, add it to this service's cache,
|
|
278
|
+
// and return it
|
|
279
|
+
|
|
280
|
+
// Let's try to get the ibGib from the space first to get the UUID.
|
|
281
|
+
// We'll need the metaspace and space instance.
|
|
282
|
+
metaspace ??= await getGlobalMetaspace_waitIfNeeded();
|
|
283
|
+
const space = await metaspace.getLocalUserSpace({
|
|
284
|
+
localSpaceId: spaceId,
|
|
285
|
+
lock: false
|
|
286
|
+
});
|
|
287
|
+
if (!space) {
|
|
288
|
+
if (spaceId) {
|
|
289
|
+
throw new Error(`couldn't get space with spaceId (${spaceId}) (E: 26b3f1414a93cc339e704d0162cb8b25)`);
|
|
290
|
+
} else {
|
|
291
|
+
throw new Error(`(UNEXPECTED) couldn't get default local user space? (E: 2e19a1fae8b3f00595257f51426ac225)`);
|
|
292
|
+
}
|
|
293
|
+
}
|
|
294
|
+
|
|
295
|
+
const resGet = await metaspace.get({ addrs: [agentAddr], space, });
|
|
296
|
+
if (!resGet.success || !resGet.ibGibs || resGet.ibGibs.length === 0) {
|
|
297
|
+
if (logalot) { console.log(`${lc} Agent ibGib not found in space (${spaceId}) at address ${agentAddr}. (I: 29c5c7994fb3ed388b28a81a9ed68325)`); }
|
|
298
|
+
return undefined; // Agent not found in the space
|
|
299
|
+
}
|
|
300
|
+
const agentIbGib = resGet.ibGibs[0] as AgentWitnessIbGib_V1;
|
|
301
|
+
|
|
302
|
+
// 3. Convert DTO to Witness
|
|
303
|
+
const agentWitness = await this.getAgentWitnessFromDto({ dto: agentIbGib });
|
|
304
|
+
if (!agentWitness) {
|
|
305
|
+
debugger; // error couldn't get agent from dto?
|
|
306
|
+
throw new Error(`${lc} Couldn't get actual agent witness from agent dto (${agentAddr}). Have we registered classname (${agentIbGib.data?.classname}) and factory fn with agents service? (E: e6e9da6c91d14bd7acb5c571c8de1a25)`);
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// 4. Cache the witness
|
|
310
|
+
await this.updateOrSetLatestAgent({
|
|
311
|
+
agent: agentWitness,
|
|
312
|
+
throwIfNewerFound: true, // we just checked, it would be weird if already exists
|
|
313
|
+
});
|
|
314
|
+
if (logalot) { console.log(`${lc} Cached agent witness with id ${agentId}. (I: b862f63147a3fac3c6e6210d5ab87c25)`); }
|
|
315
|
+
|
|
316
|
+
if (logalot) { console.log(`${lc} complete. Retrieved and cached agent witness for address ${agentAddr}.`); }
|
|
317
|
+
return agentWitness;
|
|
318
|
+
} catch (error) {
|
|
319
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
320
|
+
throw error;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
/**
|
|
325
|
+
* factory function that creates a new agent ibgib and witness. this **DOES**
|
|
326
|
+
* save all created ibgibs (including dependency and intermediate ibgibs) in the
|
|
327
|
+
* given {@link space} if provided, else the default local space according to
|
|
328
|
+
* the given {@link metaspace}.
|
|
329
|
+
*/
|
|
330
|
+
async createNewAgent(arg: CreateNewAgentArg): Promise<CreateNewAgentResult> {
|
|
331
|
+
const lc = `[${this.createNewAgent.name}]`;
|
|
332
|
+
try {
|
|
333
|
+
if (logalot) { console.log(`${lc} starting... (I: a3e07b54bb7bf45f7739eff2d738c825)`); }
|
|
334
|
+
let {
|
|
335
|
+
metaspace,
|
|
336
|
+
superSpace,
|
|
337
|
+
name,
|
|
338
|
+
// api, // extracted and used in getConcreteAgentFactory
|
|
339
|
+
// model, // extracted and used in getConcreteAgentFactory
|
|
340
|
+
availableFunctions,
|
|
341
|
+
initialSystemText,
|
|
342
|
+
initialChatText,
|
|
343
|
+
fnGetAPIKey,
|
|
344
|
+
addToAgentsTag,
|
|
345
|
+
type,
|
|
346
|
+
} = arg;
|
|
347
|
+
superSpace ??= await metaspace.getLocalUserSpace({});
|
|
348
|
+
if (!superSpace) { throw new Error(`(UNEXPECTED) superSpace falsy? (E: ceb60d96ff25b6d6aaa5aa69a7a51d25)`); }
|
|
349
|
+
if (!superSpace.data) { throw new Error(`(UNEXPECTED) superSpace.data falsy? (E: 56b4ec127f8559da96e6f70c7cb13825)`); }
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* this sets the factory to the given {@link arg}
|
|
353
|
+
*/
|
|
354
|
+
const agentFactory = getConcreteAgentFactory(arg);
|
|
355
|
+
|
|
356
|
+
// do the data (should be in concrete api function, pass in superSpaceId)
|
|
357
|
+
const data = await agentFactory.createInitialData(superSpace);
|
|
358
|
+
if (!data.uuid) { throw new Error(`(UNEXPECTED) data.uuid falsy? (E: 4e4f6fcf89d1e3775971ad843a083725)`); }
|
|
359
|
+
|
|
360
|
+
const newSubSpace = await metaspace.createLocalSpaceAndUpdateBootstrap({
|
|
361
|
+
allowCancel: false,
|
|
362
|
+
zeroSpace: metaspace.zeroSpace,
|
|
363
|
+
spaceName: name + data.uuid.substring(0, 5), // arbitrary
|
|
364
|
+
createBootstrap: false,
|
|
365
|
+
});
|
|
366
|
+
// let debugerrors = await validateIbGibIntrinsically({ ibGib: newSubSpace! }) ?? []; // debugging
|
|
367
|
+
// console.log(`${lc}\n${debugerrors?.join('\n')}`)
|
|
368
|
+
if (!newSubSpace) { throw new Error(`(UNEXPECTED) newSubSpace falsy after creating locally? (E: af8b5503c15d4292e2f591b316e7d825)`); }
|
|
369
|
+
data.subSpaceId = newSubSpace.data!.uuid;
|
|
370
|
+
|
|
371
|
+
// do the rel8ns (should be in concrete api function, pass in superSpaceId)
|
|
372
|
+
// const rel8ns = !!DEFAULT_AGENT_REL8NS_V1 ?
|
|
373
|
+
// clone(DEFAULT_AGENT_REL8NS_V1) as AgentWitnessRel8ns_V1 :
|
|
374
|
+
// undefined;
|
|
375
|
+
const rel8ns = await agentFactory.createInitialRel8ns();
|
|
376
|
+
|
|
377
|
+
const resFirstGen = await Factory_V1.firstGen({
|
|
378
|
+
ib: getAgentIb({ data }),
|
|
379
|
+
parentIbGib: Factory_V1.primitive({ ib: AGENT_ATOM }),
|
|
380
|
+
data, rel8ns,
|
|
381
|
+
nCounter: true, dna: true,
|
|
382
|
+
tjp: { timestamp: true, },
|
|
383
|
+
});
|
|
384
|
+
await metaspace.persistTransformResult({ resTransform: resFirstGen });
|
|
385
|
+
// await metaspace.registerNewIbGib
|
|
386
|
+
// skipping registering new ibgib with metaspace for now. maybe should
|
|
387
|
+
// do this, I don't remember.
|
|
388
|
+
const agentIbGib = resFirstGen.newIbGib as AgentWitnessIbGib_V1;
|
|
389
|
+
const agentWitness = await agentFactory.createWitness();
|
|
390
|
+
// agentWitness.setMetaspace(metaspace); // must set metaspace 1st
|
|
391
|
+
|
|
392
|
+
agentWitness.fnGetAPIKey = fnGetAPIKey;
|
|
393
|
+
await agentWitness.loadIbGibDto(agentIbGib);
|
|
394
|
+
|
|
395
|
+
if (addToAgentsTag) {
|
|
396
|
+
const agentsTagIbGib = await getTag_Agents({ metaspace, space: superSpace, });
|
|
397
|
+
// this will persist the new agents tag and register it with the
|
|
398
|
+
// given superSpace
|
|
399
|
+
let _newAgentsTagIbGib = await rel8ToTag({
|
|
400
|
+
ibGib: agentIbGib, // just need the dto
|
|
401
|
+
metaspace,
|
|
402
|
+
space: superSpace,
|
|
403
|
+
tagIbGib: agentsTagIbGib,
|
|
404
|
+
});
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
// always add to agent index
|
|
408
|
+
await updateSpecialIndex({
|
|
409
|
+
type,
|
|
410
|
+
rel8nInfos: [{ rel8nName: AGENT_REL8N_NAME, ibGibs: [agentIbGib], }],
|
|
411
|
+
metaspace,
|
|
412
|
+
space: superSpace,
|
|
413
|
+
});
|
|
414
|
+
|
|
415
|
+
// at this point, we should have a witness that is able to build itself
|
|
416
|
+
// up with its own functions.
|
|
417
|
+
|
|
418
|
+
if (availableFunctions.length > 0) {
|
|
419
|
+
await agentWitness.addAvailableFunctions(availableFunctions);
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
const textsToAdd: AddTextInfo[] = [];
|
|
423
|
+
// always tell the agent their id, superSpaceId and subSpaceId
|
|
424
|
+
textsToAdd.push({
|
|
425
|
+
textSrc: 'hardcoded',
|
|
426
|
+
text: taggifyForPrompt({
|
|
427
|
+
tagText: HARDCODED_PROMPT_TAG_TEXT,
|
|
428
|
+
contentText: `Your id (agent id) is: ${data.uuid}. Your superSpaceId is: ${data.superSpaceId}. Your subSpaceId is: ${data.subSpaceId}. These may be useful/required in some functions, though you should refer to those functions' instructions/descriptions for applicability.`,
|
|
429
|
+
}),
|
|
430
|
+
isSystem: true,
|
|
431
|
+
});
|
|
432
|
+
|
|
433
|
+
if (initialSystemText) {
|
|
434
|
+
textsToAdd.push({ textSrc: 'hardcoded', text: initialSystemText, isSystem: true, });
|
|
435
|
+
}
|
|
436
|
+
if (initialChatText) {
|
|
437
|
+
textsToAdd.push({ textSrc: 'hardcoded', text: initialChatText, });
|
|
438
|
+
}
|
|
439
|
+
await agentWitness.addTexts({ infos: textsToAdd, });
|
|
440
|
+
|
|
441
|
+
this.latestAgents.set(agentWitness.data!.uuid!, agentWitness);
|
|
442
|
+
|
|
443
|
+
return agentWitness;
|
|
444
|
+
} catch (error) {
|
|
445
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
446
|
+
throw error;
|
|
447
|
+
} finally {
|
|
448
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
449
|
+
}
|
|
450
|
+
}
|
|
451
|
+
|
|
452
|
+
getAgents(opts: {
|
|
453
|
+
metaspace: MetaspaceService,
|
|
454
|
+
type: SpecialIbGibType,
|
|
455
|
+
spaceId?: SpaceId,
|
|
456
|
+
space?: IbGibSpaceAny,
|
|
457
|
+
}): Promise<AgentWitnessAny[]> {
|
|
458
|
+
const lc = `${this.lc}[${this.getAgents.name}]`;
|
|
459
|
+
try {
|
|
460
|
+
if (logalot) { console.log(`${lc} starting... (I: 4663f125c3a21fa3ecccc2c5a38d1225)`); }
|
|
461
|
+
return getAgents(opts);
|
|
462
|
+
} catch (error) {
|
|
463
|
+
console.error(`${lc} ${extractErrorMsg(error)}`);
|
|
464
|
+
throw error;
|
|
465
|
+
} finally {
|
|
466
|
+
if (logalot) { console.log(`${lc} complete.`); }
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
/**
|
|
474
|
+
* Singleton {@link AgentsService_V1} instance.
|
|
475
|
+
*/
|
|
476
|
+
let _agentsSvcInstance: AgentsService_V1 | undefined = undefined;
|
|
477
|
+
export function getAgentsSvc(): AgentsService_V1 {
|
|
478
|
+
if (!_agentsSvcInstance) {
|
|
479
|
+
_agentsSvcInstance = new AgentsService_V1();
|
|
480
|
+
}
|
|
481
|
+
return _agentsSvcInstance;
|
|
482
|
+
}
|