@opengeni/core 3.0.1 → 3.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -4
- package/dist/access/index.d.ts +131 -7
- package/dist/access/service-initiator.d.ts +3 -0
- package/dist/application/archived-session-imports.d.ts +6 -0
- package/dist/application/composer-submit.d.ts +1 -1
- package/dist/application/connect-operation.d.ts +6 -0
- package/dist/application/external-workspace-members.d.ts +13 -1
- package/dist/application/modal-native-live-declaration-join.d.ts +37 -0
- package/dist/application/modal-native-original-configuration.d.ts +79 -0
- package/dist/application/modal-native-worker-host-transport.d.ts +297 -0
- package/dist/application/new-session-drafts.d.ts +29 -2
- package/dist/application/organization-privacy.d.ts +57 -0
- package/dist/application/prepared-mcp-connection.d.ts +31 -0
- package/dist/application/sandbox-recovery.d.ts +58 -0
- package/dist/application/session-commands.d.ts +3 -0
- package/dist/application/session-tenancy.d.ts +13 -4
- package/dist/billing/agent-run-admission.d.ts +21 -0
- package/dist/billing/limits.d.ts +27 -1
- package/dist/billing/model-call-admission.d.ts +34 -0
- package/dist/billing/model-usage-settlement.d.ts +112 -0
- package/dist/canonical-human-identities.js +1 -1
- package/dist/{chunk-VCZFFEPB.js → chunk-7T2SZ7BI.js} +16 -2
- package/dist/chunk-7T2SZ7BI.js.map +1 -0
- package/dist/{chunk-ZYCNLYGH.js → chunk-OMJFIIWK.js} +178 -12
- package/dist/chunk-OMJFIIWK.js.map +1 -0
- package/dist/{chunk-H7X52RI2.js → chunk-QI2M2B2K.js} +83 -8
- package/dist/chunk-QI2M2B2K.js.map +1 -0
- package/dist/{chunk-OF65T3PM.js → chunk-TTWTXQB2.js} +94 -6
- package/dist/chunk-TTWTXQB2.js.map +1 -0
- package/dist/codex-model-availability.d.ts +55 -0
- package/dist/default-session-model.d.ts +192 -0
- package/dist/dependencies.d.ts +41 -7
- package/dist/developer-setup-credential-ceiling.d.ts +10 -0
- package/dist/domain/agent-config-resolution.d.ts +49 -0
- package/dist/domain/automations.d.ts +8 -1
- package/dist/domain/capabilities.d.ts +112 -8
- package/dist/domain/connection-account-selection-error.d.ts +8 -0
- package/dist/domain/connector-tool-permissions.d.ts +62 -0
- package/dist/domain/direct-model-provider.d.ts +3 -0
- package/dist/domain/editable-artifacts/agent-application.d.ts +10 -1
- package/dist/domain/editable-artifacts/durable-export.d.ts +22 -1
- package/dist/domain/editable-artifacts/ports.d.ts +10 -0
- package/dist/domain/editable-artifacts/service.d.ts +3 -1
- package/dist/domain/editable-artifacts/types.d.ts +1 -1
- package/dist/domain/encryption-key.d.ts +12 -0
- package/dist/domain/insights-timing.d.ts +16 -0
- package/dist/domain/insights-usage.d.ts +27 -0
- package/dist/domain/insights.d.ts +21 -3
- package/dist/domain/knowledge-files.d.ts +1 -1
- package/dist/domain/knowledge-preparation.d.ts +10 -0
- package/dist/domain/knowledge-preparation.test.d.ts +1 -0
- package/dist/domain/knowledge-search.d.ts +15 -76
- package/dist/domain/mcp-account-bindings.d.ts +17 -0
- package/dist/domain/mcp-account-routes.d.ts +21 -0
- package/dist/domain/native-mcp-connection-admission.d.ts +3 -0
- package/dist/domain/organization-integration-catalog.d.ts +15 -0
- package/dist/domain/personal-connection-delegations.d.ts +73 -12
- package/dist/domain/pr-review.d.ts +121 -6
- package/dist/domain/realtime-voice-billing.d.ts +103 -0
- package/dist/domain/resources.d.ts +17 -1
- package/dist/domain/scheduled-task-access.d.ts +265 -0
- package/dist/domain/scheduled-task-account-audit.d.ts +27 -0
- package/dist/domain/scheduled-task-audience.d.ts +70 -0
- package/dist/domain/scheduled-tasks.d.ts +61 -18
- package/dist/domain/session-connection-accounts.d.ts +53 -0
- package/dist/domain/session-file-access.d.ts +4 -0
- package/dist/domain/session-native-connection-replacement.d.ts +14 -0
- package/dist/domain/session-start-timing.d.ts +7 -0
- package/dist/domain/session-tool-policy.d.ts +102 -4
- package/dist/domain/sessions.d.ts +179 -15
- package/dist/domain/site-audience.d.ts +52 -0
- package/dist/domain/skills.d.ts +29 -1
- package/dist/domain/slack-bot.d.ts +46 -1
- package/dist/domain/slack-publication-secret-safety.d.ts +1 -1
- package/dist/domain/vaults/index.d.ts +7 -0
- package/dist/domain/vaults/mapping.d.ts +25 -0
- package/dist/domain/vaults/provider-registry.d.ts +72 -0
- package/dist/domain/vaults/provider-sync.d.ts +176 -0
- package/dist/domain/vaults/provider-writes.d.ts +57 -0
- package/dist/domain/vaults/secret-resolver.d.ts +34 -0
- package/dist/domain/vaults/types.d.ts +24 -0
- package/dist/domain/vaults/vault-service.d.ts +35 -0
- package/dist/domain/voice-input-billing.d.ts +77 -0
- package/dist/domain/web-search-billing.d.ts +51 -0
- package/dist/domain/workspace-credits.d.ts +7 -0
- package/dist/editable-artifact-live/application.d.ts +2 -1
- package/dist/editable-artifact-live/server.d.ts +5 -1
- package/dist/editable-artifact-live/ticket.d.ts +2 -1
- package/dist/editable-artifact-live/types.d.ts +9 -0
- package/dist/editable-artifact-live.js +2 -2
- package/dist/editable-artifacts.js +10 -2
- package/dist/goal-admission.d.ts +627 -0
- package/dist/host-session-usage-limit.d.ts +15 -0
- package/dist/index.d.ts +43 -8
- package/dist/index.js +22682 -11743
- package/dist/index.js.map +1 -1
- package/dist/managed-session.d.ts +110 -7
- package/dist/model-call.d.ts +58 -0
- package/dist/model-catalog.d.ts +29 -3
- package/dist/model-provider-credentials.d.ts +43 -0
- package/dist/product-usage-metrics.d.ts +30 -0
- package/dist/rigs/index.d.ts +1 -13
- package/dist/sandbox/fleet.d.ts +58 -4
- package/dist/sandbox/routing.d.ts +42 -2
- package/dist/sandbox/runtime-settings.d.ts +27 -17
- package/dist/session-authorization.d.ts +10 -0
- package/dist/session-usage-limit-metrics.d.ts +60 -0
- package/dist/session-usage-limits.d.ts +89 -0
- package/dist/site-agent-clamp.d.ts +71 -0
- package/dist/site-session-origin.d.ts +39 -2
- package/dist/transcription.d.ts +120 -3
- package/dist/turn-surface.d.ts +20 -0
- package/dist/user-presence.d.ts +32 -0
- package/dist/workflow-wake-contract.d.ts +13 -1
- package/package.json +15 -22
- package/src/access/index.ts +961 -38
- package/src/access/service-initiator.ts +50 -0
- package/src/application/api-integration-servers.ts +9 -0
- package/src/application/archived-session-imports.ts +161 -0
- package/src/application/composer-submit.ts +3 -2
- package/src/application/connect-authority.ts +3 -3
- package/src/application/connect-operation.ts +37 -3
- package/src/application/external-continuation.ts +20 -3
- package/src/application/external-link-work-admission.ts +3 -0
- package/src/application/external-workspace-members.ts +51 -3
- package/src/application/modal-native-live-declaration-join.ts +196 -0
- package/src/application/modal-native-original-configuration.ts +261 -0
- package/src/application/modal-native-worker-host-transport.ts +263 -0
- package/src/application/new-session-drafts.ts +172 -55
- package/src/application/organization-privacy.ts +161 -0
- package/src/application/prepared-mcp-connection.ts +133 -0
- package/src/application/sandbox-recovery.ts +78 -0
- package/src/application/session-commands.ts +73 -1
- package/src/application/session-mcp-credential-rotation.ts +61 -18
- package/src/application/session-tenancy.ts +262 -44
- package/src/application/user-resource-grants.ts +1 -29
- package/src/billing/agent-run-admission.ts +117 -0
- package/src/billing/limits.ts +138 -14
- package/src/billing/model-call-admission.ts +118 -0
- package/src/billing/model-usage-settlement.ts +472 -0
- package/src/codex-model-availability.ts +264 -0
- package/src/default-session-model.ts +692 -0
- package/src/dependencies.ts +48 -6
- package/src/developer-setup-credential-ceiling.ts +60 -0
- package/src/domain/agent-config-resolution.ts +148 -0
- package/src/domain/automations.ts +76 -2
- package/src/domain/capabilities.ts +830 -181
- package/src/domain/connection-account-selection-error.ts +19 -0
- package/src/domain/connector-tool-permissions.ts +572 -0
- package/src/domain/direct-model-provider.ts +62 -0
- package/src/domain/editable-artifacts/agent-application.ts +44 -6
- package/src/domain/editable-artifacts/durable-export.ts +100 -5
- package/src/domain/editable-artifacts/in-memory.ts +6 -0
- package/src/domain/editable-artifacts/ports.ts +11 -0
- package/src/domain/editable-artifacts/service.ts +20 -0
- package/src/domain/editable-artifacts/types.ts +1 -1
- package/src/domain/encryption-key.ts +26 -0
- package/src/domain/file-owner.ts +16 -1
- package/src/domain/github-action-policies.ts +1 -1
- package/src/domain/github-skill-source.ts +3 -1
- package/src/domain/insights-timing.ts +95 -0
- package/src/domain/insights-usage.ts +67 -0
- package/src/domain/insights.ts +167 -43
- package/src/domain/knowledge-files.ts +10 -3
- package/src/domain/knowledge-messages.ts +1 -0
- package/src/domain/knowledge-preparation.test.ts +276 -0
- package/src/domain/knowledge-preparation.ts +147 -0
- package/src/domain/knowledge-search.test.ts +617 -5
- package/src/domain/knowledge-search.ts +240 -23
- package/src/domain/mcp-account-bindings.ts +169 -0
- package/src/domain/mcp-account-routes.ts +152 -0
- package/src/domain/native-mcp-connection-admission.ts +14 -0
- package/src/domain/organization-integration-catalog.ts +88 -0
- package/src/domain/personal-connection-delegations.ts +399 -257
- package/src/domain/pr-review.ts +24 -8
- package/src/domain/realtime-voice-billing.ts +425 -0
- package/src/domain/resources.ts +50 -4
- package/src/domain/scheduled-task-access.ts +1089 -0
- package/src/domain/scheduled-task-account-audit.ts +90 -0
- package/src/domain/scheduled-task-audience.ts +249 -0
- package/src/domain/scheduled-tasks.ts +1313 -374
- package/src/domain/session-connection-accounts.ts +239 -0
- package/src/domain/session-file-access.ts +47 -0
- package/src/domain/session-native-connection-replacement.ts +64 -0
- package/src/domain/session-start-timing.ts +60 -0
- package/src/domain/session-tool-policy.ts +489 -14
- package/src/domain/sessions.ts +2254 -717
- package/src/domain/site-audience.ts +130 -0
- package/src/domain/skills.ts +9 -0
- package/src/domain/slack-bot.ts +141 -4
- package/src/domain/slack-publication-secret-safety.ts +1 -1
- package/src/domain/vaults/index.ts +19 -0
- package/src/domain/vaults/mapping.ts +190 -0
- package/src/domain/vaults/provider-registry.ts +201 -0
- package/src/domain/vaults/provider-sync.ts +531 -0
- package/src/domain/vaults/provider-writes.ts +288 -0
- package/src/domain/vaults/secret-resolver.ts +464 -0
- package/src/domain/vaults/types.ts +26 -0
- package/src/domain/vaults/vault-service.ts +1316 -0
- package/src/domain/voice-input-billing.ts +330 -0
- package/src/domain/web-search-billing.ts +169 -0
- package/src/domain/workspace-credits.ts +13 -0
- package/src/editable-artifact-live/application.ts +8 -1
- package/src/editable-artifact-live/server.ts +154 -6
- package/src/editable-artifact-live/ticket.ts +86 -1
- package/src/editable-artifact-live/types.ts +10 -0
- package/src/goal-admission.ts +220 -0
- package/src/host-session-usage-limit.ts +25 -0
- package/src/index.ts +75 -11
- package/src/managed-session.ts +137 -6
- package/src/model-call.ts +79 -0
- package/src/model-catalog.ts +345 -91
- package/src/model-provider-credentials.ts +394 -0
- package/src/product-usage-metrics.ts +101 -0
- package/src/rigs/index.ts +23 -111
- package/src/sandbox/fleet.ts +253 -28
- package/src/sandbox/routing.ts +204 -43
- package/src/sandbox/runtime-settings.ts +159 -85
- package/src/session-authorization.ts +172 -23
- package/src/session-usage-limit-metrics.ts +95 -0
- package/src/session-usage-limits.ts +415 -0
- package/src/site-agent-clamp.ts +226 -0
- package/src/site-session-origin.ts +84 -5
- package/src/transcription.ts +123 -4
- package/src/turn-surface.ts +47 -0
- package/src/user-presence.ts +134 -0
- package/src/workflow-wake-contract.ts +14 -1
- package/dist/application/host-mcp-owner.d.ts +0 -6
- package/dist/application/host-mcp-resolvers.d.ts +0 -13
- package/dist/chunk-5WZYFL45.js +0 -266
- package/dist/chunk-5WZYFL45.js.map +0 -1
- package/dist/chunk-H7X52RI2.js.map +0 -1
- package/dist/chunk-OF65T3PM.js.map +0 -1
- package/dist/chunk-VCZFFEPB.js.map +0 -1
- package/dist/chunk-ZYCNLYGH.js.map +0 -1
- package/dist/domain/connection-authority.d.ts +0 -97
- package/dist/domain/connection-authority.js +0 -169
- package/dist/domain/connection-authority.js.map +0 -1
- package/dist/domain/environments.d.ts +0 -33
- package/dist/domain/host-mcp-authority-source-admission.d.ts +0 -10
- package/dist/domain/host-mcp-task-admission.d.ts +0 -18
- package/dist/domain/packs.d.ts +0 -59
- package/dist/domain/product-integration-pack.d.ts +0 -44
- package/dist/domain/product-integration-skill.gen.d.ts +0 -5
- package/dist/remote-mcp-credentials.d.ts +0 -23
- package/dist/remote-mcp-credentials.js +0 -11
- package/dist/remote-mcp-credentials.js.map +0 -1
- package/src/application/host-mcp-owner.ts +0 -41
- package/src/application/host-mcp-resolvers.ts +0 -84
- package/src/domain/connection-authority.ts +0 -329
- package/src/domain/environments.ts +0 -120
- package/src/domain/host-mcp-authority-source-admission.ts +0 -25
- package/src/domain/host-mcp-task-admission.ts +0 -121
- package/src/domain/packs.ts +0 -699
- package/src/domain/product-integration-pack.ts +0 -42
- package/src/domain/product-integration-skill.gen.ts +0 -52
- package/src/remote-mcp-credentials.ts +0 -361
package/src/domain/packs.ts
DELETED
|
@@ -1,699 +0,0 @@
|
|
|
1
|
-
import { createHash } from "node:crypto";
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
CapabilityPack,
|
|
5
|
-
StoredCapabilityPack,
|
|
6
|
-
OPENGENI_PR_REVIEW_PACK_ID,
|
|
7
|
-
OPENGENI_PR_REVIEW_SESSION_ROLE,
|
|
8
|
-
stableJson,
|
|
9
|
-
type CapabilityPackSkill,
|
|
10
|
-
type PackComponentResolution,
|
|
11
|
-
type PackInstallationPreview,
|
|
12
|
-
type PackRigResolution,
|
|
13
|
-
type ScheduledTaskAgentConfig,
|
|
14
|
-
type SocialConnection,
|
|
15
|
-
} from "@opengeni/contracts";
|
|
16
|
-
import {
|
|
17
|
-
getPackInstallation,
|
|
18
|
-
getRig,
|
|
19
|
-
getVariableSet,
|
|
20
|
-
getWorkspacePack,
|
|
21
|
-
listPackInstallations,
|
|
22
|
-
listWorkspacePacks,
|
|
23
|
-
resolvePackComponentReferences,
|
|
24
|
-
resolvePackInlineSkillReferences,
|
|
25
|
-
type Database,
|
|
26
|
-
} from "@opengeni/db";
|
|
27
|
-
import { buildPortableSkillArtifact } from "@opengeni/runtime/skill-library";
|
|
28
|
-
import { HTTPException } from "hono/http-exception";
|
|
29
|
-
import {
|
|
30
|
-
OPENGENI_PR_REVIEW_AGENT_INSTRUCTIONS,
|
|
31
|
-
OPENGENI_PR_REVIEW_SKILL,
|
|
32
|
-
PR_REVIEW_AUTOMATION_ADAPTER_ID,
|
|
33
|
-
PR_REVIEW_AUTOMATION_TEMPLATE_ID,
|
|
34
|
-
} from "./pr-review";
|
|
35
|
-
import { OPENGENI_PRODUCT_INTEGRATION_PACK } from "./product-integration-pack";
|
|
36
|
-
|
|
37
|
-
export const MARKETING_SOCIAL_PACK_ID = "marketing-social-daily-analysis";
|
|
38
|
-
|
|
39
|
-
const marketingSocialPack: CapabilityPack = {
|
|
40
|
-
id: MARKETING_SOCIAL_PACK_ID,
|
|
41
|
-
name: "Marketing social daily analysis",
|
|
42
|
-
description:
|
|
43
|
-
"Connect social accounts, attach marketing knowledge, and schedule agents to produce daily media performance analysis.",
|
|
44
|
-
role: "marketing",
|
|
45
|
-
category: "social-media",
|
|
46
|
-
version: "0.1.0",
|
|
47
|
-
// Built-in packs deliberately declare no sandboxImage and no skills: the
|
|
48
|
-
// worker's pack-runtime resolution only reads manifest-registered packs
|
|
49
|
-
// (see apps/worker/src/activities/packs.ts), and a test enforces this.
|
|
50
|
-
skills: [],
|
|
51
|
-
components: [],
|
|
52
|
-
automationTemplates: [],
|
|
53
|
-
tools: [
|
|
54
|
-
{ kind: "mcp", id: "opengeni" },
|
|
55
|
-
{ kind: "mcp", id: "docs" },
|
|
56
|
-
],
|
|
57
|
-
connectors: [
|
|
58
|
-
{
|
|
59
|
-
id: "x",
|
|
60
|
-
name: "X",
|
|
61
|
-
category: "social-media",
|
|
62
|
-
authModel: "oauth2_authorization_code_pkce",
|
|
63
|
-
providers: ["x"],
|
|
64
|
-
scopes: ["tweet.read", "tweet.write", "users.read", "offline.access"],
|
|
65
|
-
required: false,
|
|
66
|
-
metadata: {
|
|
67
|
-
docs: "https://docs.x.com/fundamentals/authentication/oauth-2-0/authorization-code",
|
|
68
|
-
firstParty: true,
|
|
69
|
-
oauthStartPath: "/social/oauth/start",
|
|
70
|
-
},
|
|
71
|
-
},
|
|
72
|
-
{
|
|
73
|
-
id: "reddit",
|
|
74
|
-
name: "Reddit",
|
|
75
|
-
category: "social-media",
|
|
76
|
-
authModel: "oauth2_authorization_code",
|
|
77
|
-
providers: ["reddit"],
|
|
78
|
-
scopes: ["identity", "read", "submit", "privatemessages", "history"],
|
|
79
|
-
required: false,
|
|
80
|
-
metadata: {
|
|
81
|
-
docs: "https://github.com/reddit-archive/reddit/wiki/OAuth2",
|
|
82
|
-
firstParty: true,
|
|
83
|
-
oauthStartPath: "/social/oauth/start",
|
|
84
|
-
},
|
|
85
|
-
},
|
|
86
|
-
{
|
|
87
|
-
id: "linkedin",
|
|
88
|
-
name: "LinkedIn",
|
|
89
|
-
category: "social-media",
|
|
90
|
-
authModel: "oauth2_authorization_code",
|
|
91
|
-
providers: ["linkedin"],
|
|
92
|
-
scopes: ["r_organization_social", "rw_organization_admin"],
|
|
93
|
-
required: false,
|
|
94
|
-
metadata: {
|
|
95
|
-
docs: "https://learn.microsoft.com/en-us/linkedin/marketing/community-management/community-management-overview",
|
|
96
|
-
},
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
id: "instagram",
|
|
100
|
-
name: "Instagram",
|
|
101
|
-
category: "social-media",
|
|
102
|
-
authModel: "oauth2_authorization_code",
|
|
103
|
-
providers: ["instagram", "facebook"],
|
|
104
|
-
scopes: [
|
|
105
|
-
"instagram_basic",
|
|
106
|
-
"instagram_manage_insights",
|
|
107
|
-
"pages_read_engagement",
|
|
108
|
-
"pages_show_list",
|
|
109
|
-
],
|
|
110
|
-
required: false,
|
|
111
|
-
metadata: {
|
|
112
|
-
docs: "https://developers.facebook.com/docs/instagram-platform/instagram-graph-api/",
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
id: "tiktok",
|
|
117
|
-
name: "TikTok",
|
|
118
|
-
category: "social-media",
|
|
119
|
-
authModel: "oauth2_authorization_code",
|
|
120
|
-
providers: ["tiktok"],
|
|
121
|
-
scopes: ["user.info.basic", "video.list"],
|
|
122
|
-
required: false,
|
|
123
|
-
metadata: {
|
|
124
|
-
docs: "https://developers.tiktok.com/doc/tiktok-api-v2-introduction/",
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
id: "youtube",
|
|
129
|
-
name: "YouTube",
|
|
130
|
-
category: "social-media",
|
|
131
|
-
authModel: "oauth2_authorization_code",
|
|
132
|
-
providers: ["youtube"],
|
|
133
|
-
scopes: [
|
|
134
|
-
"https://www.googleapis.com/auth/youtube.readonly",
|
|
135
|
-
"https://www.googleapis.com/auth/yt-analytics.readonly",
|
|
136
|
-
],
|
|
137
|
-
required: false,
|
|
138
|
-
metadata: {
|
|
139
|
-
docs: "https://developers.google.com/youtube/v3",
|
|
140
|
-
},
|
|
141
|
-
},
|
|
142
|
-
],
|
|
143
|
-
knowledge: [
|
|
144
|
-
{
|
|
145
|
-
type: "document_base",
|
|
146
|
-
id: "marketing-playbook",
|
|
147
|
-
name: "Marketing playbook",
|
|
148
|
-
description:
|
|
149
|
-
"Optional workspace document base with brand voice, campaign calendars, audience research, and reporting rules.",
|
|
150
|
-
required: false,
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
scheduledTaskTemplates: [
|
|
154
|
-
{
|
|
155
|
-
id: "daily-social-analysis",
|
|
156
|
-
name: "Daily social analysis",
|
|
157
|
-
description: "Review the latest social posts and account signals every day.",
|
|
158
|
-
defaultSchedule: {
|
|
159
|
-
type: "calendar",
|
|
160
|
-
timeZone: "UTC",
|
|
161
|
-
hour: 9,
|
|
162
|
-
minute: 0,
|
|
163
|
-
},
|
|
164
|
-
defaultRunMode: "new_session_per_run",
|
|
165
|
-
defaultOverlapPolicy: "skip",
|
|
166
|
-
},
|
|
167
|
-
],
|
|
168
|
-
metadata: {
|
|
169
|
-
skill: "social-media-marketing",
|
|
170
|
-
firstPartyMcpTools: [
|
|
171
|
-
"social_connections_list",
|
|
172
|
-
"social_posts_recent",
|
|
173
|
-
"social_daily_analysis_context",
|
|
174
|
-
"x_accounts_list",
|
|
175
|
-
"x_search_live",
|
|
176
|
-
"x_mentions_live",
|
|
177
|
-
"x_thread_fetch",
|
|
178
|
-
"x_posts_sync",
|
|
179
|
-
"x_post_reply",
|
|
180
|
-
"reddit_accounts_list",
|
|
181
|
-
"reddit_search_live",
|
|
182
|
-
"reddit_mentions_live",
|
|
183
|
-
"reddit_thread_fetch",
|
|
184
|
-
"reddit_posts_sync",
|
|
185
|
-
"reddit_post_reply",
|
|
186
|
-
],
|
|
187
|
-
},
|
|
188
|
-
};
|
|
189
|
-
|
|
190
|
-
const openGeniPrReviewPack: CapabilityPack = {
|
|
191
|
-
id: OPENGENI_PR_REVIEW_PACK_ID,
|
|
192
|
-
name: "OpenGeni Review Bot",
|
|
193
|
-
description:
|
|
194
|
-
"Run provider-neutral, exact-head pull-request reviews from GitHub, GitLab, or Azure DevOps webhooks.",
|
|
195
|
-
role: "software-engineering",
|
|
196
|
-
category: "code-review",
|
|
197
|
-
version: "0.2.0",
|
|
198
|
-
skills: [OPENGENI_PR_REVIEW_SKILL],
|
|
199
|
-
components: [],
|
|
200
|
-
tools: [],
|
|
201
|
-
connectors: [
|
|
202
|
-
{
|
|
203
|
-
id: "github",
|
|
204
|
-
name: "GitHub App",
|
|
205
|
-
category: "source-control",
|
|
206
|
-
authModel: "credential_ref",
|
|
207
|
-
providers: ["github"],
|
|
208
|
-
scopes: ["metadata:read", "contents:read", "pull_requests:write"],
|
|
209
|
-
required: false,
|
|
210
|
-
metadata: {
|
|
211
|
-
oneOf: "source-control-provider",
|
|
212
|
-
setupPath: "/pr-review/registrations",
|
|
213
|
-
webhookEvents: ["pull_request"],
|
|
214
|
-
credentialMode: "short_lived_installation_token",
|
|
215
|
-
},
|
|
216
|
-
},
|
|
217
|
-
{
|
|
218
|
-
id: "gitlab",
|
|
219
|
-
name: "GitLab project token",
|
|
220
|
-
category: "source-control",
|
|
221
|
-
authModel: "credential_ref",
|
|
222
|
-
providers: ["gitlab"],
|
|
223
|
-
scopes: ["api", "read_repository"],
|
|
224
|
-
required: false,
|
|
225
|
-
metadata: {
|
|
226
|
-
oneOf: "source-control-provider",
|
|
227
|
-
setupPath: "/pr-review/registrations",
|
|
228
|
-
webhookEvents: ["Merge Request Hook"],
|
|
229
|
-
credentialMode: "provider_token",
|
|
230
|
-
},
|
|
231
|
-
},
|
|
232
|
-
{
|
|
233
|
-
id: "azure-devops",
|
|
234
|
-
name: "Azure DevOps identity token",
|
|
235
|
-
category: "source-control",
|
|
236
|
-
authModel: "credential_ref",
|
|
237
|
-
providers: ["azure_devops"],
|
|
238
|
-
scopes: ["vso.code", "vso.threads_full"],
|
|
239
|
-
required: false,
|
|
240
|
-
metadata: {
|
|
241
|
-
oneOf: "source-control-provider",
|
|
242
|
-
setupPath: "/pr-review/registrations",
|
|
243
|
-
webhookEvents: ["git.pullrequest.created", "git.pullrequest.updated"],
|
|
244
|
-
credentialMode: "provider_token",
|
|
245
|
-
},
|
|
246
|
-
},
|
|
247
|
-
],
|
|
248
|
-
knowledge: [],
|
|
249
|
-
scheduledTaskTemplates: [],
|
|
250
|
-
automationTemplates: [
|
|
251
|
-
{
|
|
252
|
-
id: PR_REVIEW_AUTOMATION_TEMPLATE_ID,
|
|
253
|
-
name: "Review pull requests",
|
|
254
|
-
description: "Start one exact-head review session for each accepted pull-request revision.",
|
|
255
|
-
adapterId: PR_REVIEW_AUTOMATION_ADAPTER_ID,
|
|
256
|
-
eventTypes: ["pull_request.review_requested"],
|
|
257
|
-
configuration: {},
|
|
258
|
-
connectionRequirement: "source-control-provider",
|
|
259
|
-
sessionTemplate: {
|
|
260
|
-
prompt: "Review the accepted pull-request revision and publish actionable findings.",
|
|
261
|
-
instructions: OPENGENI_PR_REVIEW_AGENT_INSTRUCTIONS,
|
|
262
|
-
resources: [],
|
|
263
|
-
skills: [OPENGENI_PR_REVIEW_SKILL],
|
|
264
|
-
tools: [],
|
|
265
|
-
firstPartyMcpTools: [],
|
|
266
|
-
firstPartyMcpPermissions: [],
|
|
267
|
-
model: null,
|
|
268
|
-
reasoningEffort: null,
|
|
269
|
-
sandboxBackend: null,
|
|
270
|
-
policyRole: OPENGENI_PR_REVIEW_SESSION_ROLE,
|
|
271
|
-
metadata: { role: OPENGENI_PR_REVIEW_SESSION_ROLE },
|
|
272
|
-
},
|
|
273
|
-
},
|
|
274
|
-
],
|
|
275
|
-
metadata: {
|
|
276
|
-
automation: "pull_request_review",
|
|
277
|
-
providers: ["github", "gitlab", "azure_devops"],
|
|
278
|
-
sessionRole: "pull_request_review",
|
|
279
|
-
},
|
|
280
|
-
};
|
|
281
|
-
|
|
282
|
-
const packs = [
|
|
283
|
-
marketingSocialPack,
|
|
284
|
-
openGeniPrReviewPack,
|
|
285
|
-
OPENGENI_PRODUCT_INTEGRATION_PACK,
|
|
286
|
-
] satisfies CapabilityPack[];
|
|
287
|
-
|
|
288
|
-
export function listCapabilityPacks(): CapabilityPack[] {
|
|
289
|
-
return packs;
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
export function getCapabilityPack(packId: string): CapabilityPack | null {
|
|
293
|
-
return packs.find((pack) => pack.id === packId) ?? null;
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
export function isBuiltInCapabilityPack(packId: string): boolean {
|
|
297
|
-
return getCapabilityPack(packId) !== null;
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
/**
|
|
301
|
-
* Built-in packs plus the manifests registered for this workspace. Stored
|
|
302
|
-
* manifests retain exact historical bytes. Execution views derive Skill labels
|
|
303
|
-
* from their files, but malformed content needs explicit repair, not omission.
|
|
304
|
-
*/
|
|
305
|
-
export async function listWorkspaceCapabilityPacks(
|
|
306
|
-
db: Database,
|
|
307
|
-
workspaceId: string,
|
|
308
|
-
): Promise<CapabilityPack[]> {
|
|
309
|
-
const registered = await listWorkspacePacks(db, workspaceId);
|
|
310
|
-
const builtInIds = new Set(packs.map((pack) => pack.id));
|
|
311
|
-
const registeredPacks = registered
|
|
312
|
-
.filter((registration) => !builtInIds.has(registration.pack.id))
|
|
313
|
-
.map((registration) => {
|
|
314
|
-
const parsed = StoredCapabilityPack.safeParse(registration.pack);
|
|
315
|
-
if (!parsed.success)
|
|
316
|
-
throw new HTTPException(422, {
|
|
317
|
-
message: `Stored Pack ${registration.pack.id} requires repair before it can be used: ${parsed.error.message}`,
|
|
318
|
-
});
|
|
319
|
-
return parsed.data;
|
|
320
|
-
});
|
|
321
|
-
return [...packs, ...registeredPacks];
|
|
322
|
-
}
|
|
323
|
-
|
|
324
|
-
export async function resolveCapabilityPack(
|
|
325
|
-
db: Database,
|
|
326
|
-
workspaceId: string,
|
|
327
|
-
packId: string,
|
|
328
|
-
): Promise<CapabilityPack | null> {
|
|
329
|
-
const builtIn = getCapabilityPack(packId);
|
|
330
|
-
if (builtIn) {
|
|
331
|
-
return builtIn;
|
|
332
|
-
}
|
|
333
|
-
const registration = await getWorkspacePack(db, workspaceId, packId);
|
|
334
|
-
if (!registration) {
|
|
335
|
-
return null;
|
|
336
|
-
}
|
|
337
|
-
const parsed = StoredCapabilityPack.safeParse(registration.pack);
|
|
338
|
-
if (!parsed.success)
|
|
339
|
-
throw new HTTPException(422, {
|
|
340
|
-
message: `Stored Pack ${packId} requires repair before it can be used: ${parsed.error.message}`,
|
|
341
|
-
});
|
|
342
|
-
return parsed.data;
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
export function capabilityPackManifestDigest(pack: CapabilityPack): string {
|
|
346
|
-
return createHash("sha256").update(stableJson(pack)).digest("hex");
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
/** True when the Pack must use the owner-aware V2 preview/install lifecycle. */
|
|
350
|
-
export function capabilityPackRequiresInstallationPlan(pack: CapabilityPack): boolean {
|
|
351
|
-
return (
|
|
352
|
-
pack.components.length > 0 ||
|
|
353
|
-
pack.skills.length > 0 ||
|
|
354
|
-
(pack.automationTemplates?.length ?? 0) > 0 ||
|
|
355
|
-
pack.rig !== undefined ||
|
|
356
|
-
pack.sandboxImage !== undefined ||
|
|
357
|
-
pack.sandboxProviderImages !== undefined
|
|
358
|
-
);
|
|
359
|
-
}
|
|
360
|
-
|
|
361
|
-
export type InlinePackSkillInstall = {
|
|
362
|
-
componentKey: string;
|
|
363
|
-
capabilityId: string;
|
|
364
|
-
pluginKey: string;
|
|
365
|
-
sourceUrl: string;
|
|
366
|
-
repositoryUrl: string;
|
|
367
|
-
sourceCommit: string;
|
|
368
|
-
sourcePath: string;
|
|
369
|
-
name: string;
|
|
370
|
-
description: string;
|
|
371
|
-
activationMode: "workspace_managed" | "session_selected";
|
|
372
|
-
contentSha256: string;
|
|
373
|
-
totalBytes: number;
|
|
374
|
-
files: Array<{ path: string; content: string; byteSize: number; contentSha256: string }>;
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
/** Convert a legacy inline Pack Skill into the ordinary immutable Skill model. */
|
|
378
|
-
export function inlinePackSkillInstall(
|
|
379
|
-
pack: CapabilityPack,
|
|
380
|
-
skill: CapabilityPackSkill,
|
|
381
|
-
): InlinePackSkillInstall {
|
|
382
|
-
const artifact = buildPortableSkillArtifact(skill.files);
|
|
383
|
-
if (artifact.name.toLowerCase() !== skill.name.toLowerCase()) {
|
|
384
|
-
throw new HTTPException(422, {
|
|
385
|
-
message: `Pack Skill ${skill.name} has SKILL.md name ${artifact.name}; the names must match`,
|
|
386
|
-
});
|
|
387
|
-
}
|
|
388
|
-
const normalizedName = skill.name.toLowerCase();
|
|
389
|
-
const activationMode = skill.activationMode ?? "workspace_managed";
|
|
390
|
-
const activationIdentity = activationMode === "session_selected" ? "session-selected/" : "";
|
|
391
|
-
const encodedSkill = encodeURIComponent(normalizedName);
|
|
392
|
-
const sourceUrl = `https://opengeni.invalid/pack-inline-skills/${activationIdentity}${encodedSkill}/${artifact.contentSha256}`;
|
|
393
|
-
const capabilityId = `skill:pack-inline/${activationIdentity}${normalizedName}@${artifact.contentSha256}`;
|
|
394
|
-
return {
|
|
395
|
-
componentKey: `inline-skill/${normalizedName}`,
|
|
396
|
-
capabilityId,
|
|
397
|
-
pluginKey: `pack-skill/${activationIdentity}${normalizedName}/${artifact.contentSha256}`,
|
|
398
|
-
sourceUrl,
|
|
399
|
-
repositoryUrl: "https://opengeni.invalid/pack-inline-skills",
|
|
400
|
-
sourceCommit: artifact.contentSha256,
|
|
401
|
-
sourcePath: normalizedName,
|
|
402
|
-
name: artifact.name,
|
|
403
|
-
description: artifact.description,
|
|
404
|
-
activationMode,
|
|
405
|
-
contentSha256: artifact.contentSha256,
|
|
406
|
-
totalBytes: artifact.totalBytes,
|
|
407
|
-
files: artifact.files.map((file) => ({
|
|
408
|
-
path: file.path,
|
|
409
|
-
content: file.content,
|
|
410
|
-
byteSize: new TextEncoder().encode(file.content).byteLength,
|
|
411
|
-
contentSha256: createHash("sha256").update(file.content).digest("hex"),
|
|
412
|
-
})),
|
|
413
|
-
};
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
export async function previewCapabilityPackInstallation(
|
|
417
|
-
db: Database,
|
|
418
|
-
access: { accountId: string; workspaceId: string; subjectId: string },
|
|
419
|
-
pack: CapabilityPack,
|
|
420
|
-
options: { rigId?: string; variableSetId?: string } = {},
|
|
421
|
-
): Promise<PackInstallationPreview> {
|
|
422
|
-
const { workspaceId } = access;
|
|
423
|
-
const installation = await getPackInstallation(db, workspaceId, pack.id);
|
|
424
|
-
const inlineInstalls = pack.skills.map((skill) => inlinePackSkillInstall(pack, skill));
|
|
425
|
-
const manifestDigest = capabilityPackManifestDigest(pack);
|
|
426
|
-
const inlineRequirements = inlineInstalls.map((inline) => ({
|
|
427
|
-
key: inline.componentKey,
|
|
428
|
-
capabilityId: inline.capabilityId,
|
|
429
|
-
name: inline.name,
|
|
430
|
-
activationMode: inline.activationMode,
|
|
431
|
-
contentSha256: inline.contentSha256,
|
|
432
|
-
}));
|
|
433
|
-
const [referencedComponents, plannedInlineComponents, installedSessionSelectedComponents] =
|
|
434
|
-
await Promise.all([
|
|
435
|
-
resolvePackComponentReferences(db, workspaceId, pack.components),
|
|
436
|
-
resolvePackInlineSkillReferences(db, workspaceId, inlineRequirements, installation?.id),
|
|
437
|
-
installation?.status === "active" && installation.manifestDigest === manifestDigest
|
|
438
|
-
? resolvePackInlineSkillReferences(
|
|
439
|
-
db,
|
|
440
|
-
workspaceId,
|
|
441
|
-
inlineRequirements.filter(
|
|
442
|
-
(requirement) => requirement.activationMode === "session_selected",
|
|
443
|
-
),
|
|
444
|
-
)
|
|
445
|
-
: Promise.resolve([]),
|
|
446
|
-
]);
|
|
447
|
-
const installedSessionSelectedByKey = new Map(
|
|
448
|
-
installedSessionSelectedComponents.map((component) => [component.key, component]),
|
|
449
|
-
);
|
|
450
|
-
// Installation planning excludes the Pack's own current ownership so an
|
|
451
|
-
// update can replace old inline content. For launch affordances, preserve an
|
|
452
|
-
// independently resolved active facet-installation id on an exact installed
|
|
453
|
-
// manifest. A missing facet retains the future capability id and therefore
|
|
454
|
-
// cannot be mistaken for something a new session can select right now.
|
|
455
|
-
const inlineComponents = plannedInlineComponents.map((component) => {
|
|
456
|
-
const installed = installedSessionSelectedByKey.get(component.key);
|
|
457
|
-
return installed?.status === "ready" && installed.resolvedId
|
|
458
|
-
? { ...component, resolvedId: installed.resolvedId }
|
|
459
|
-
: component;
|
|
460
|
-
});
|
|
461
|
-
const components: PackComponentResolution[] = [...referencedComponents, ...inlineComponents];
|
|
462
|
-
const blockers = components
|
|
463
|
-
.filter((component) => component.required && component.status !== "ready")
|
|
464
|
-
.map((component) =>
|
|
465
|
-
component.status === "missing"
|
|
466
|
-
? `${component.label} is not installed in this workspace`
|
|
467
|
-
: `${component.label} does not match the Pack's pinned version`,
|
|
468
|
-
);
|
|
469
|
-
const rig = await resolvePackRig(
|
|
470
|
-
db,
|
|
471
|
-
workspaceId,
|
|
472
|
-
pack,
|
|
473
|
-
options.rigId,
|
|
474
|
-
installation?.selectedRigId,
|
|
475
|
-
);
|
|
476
|
-
if (
|
|
477
|
-
rig.status !== "ready" &&
|
|
478
|
-
rig.status !== "not_required" &&
|
|
479
|
-
(rig.required || rig.requestedRigId !== null || rig.rigId !== null)
|
|
480
|
-
) {
|
|
481
|
-
blockers.push(packRigBlocker(rig, pack.sandboxImage ?? null));
|
|
482
|
-
}
|
|
483
|
-
const variableSetId =
|
|
484
|
-
options.variableSetId ?? storedVariableSetId(installation?.metadata) ?? null;
|
|
485
|
-
if (pack.variableSet?.required && !variableSetId) {
|
|
486
|
-
blockers.push("Choose saved configuration before installing this Pack");
|
|
487
|
-
} else if (variableSetId) {
|
|
488
|
-
const variableSet = await getVariableSet(db, access, variableSetId);
|
|
489
|
-
if (!variableSet) {
|
|
490
|
-
blockers.push("The selected configuration no longer exists in this workspace");
|
|
491
|
-
} else {
|
|
492
|
-
const missing = (pack.variableSet?.requiredVariables ?? []).filter(
|
|
493
|
-
(name) => !variableSet.variables.some((variable) => variable.name === name),
|
|
494
|
-
);
|
|
495
|
-
if (missing.length > 0) {
|
|
496
|
-
blockers.push(`Configuration is missing required value(s): ${missing.join(", ")}`);
|
|
497
|
-
}
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
const action =
|
|
501
|
-
!installation || installation.status === "disabled"
|
|
502
|
-
? "install"
|
|
503
|
-
: installation.manifestDigest === manifestDigest
|
|
504
|
-
? "repair"
|
|
505
|
-
: "update";
|
|
506
|
-
return {
|
|
507
|
-
packId: pack.id,
|
|
508
|
-
packVersion: pack.version,
|
|
509
|
-
manifestDigest,
|
|
510
|
-
installationVersion: installation?.version ?? null,
|
|
511
|
-
action,
|
|
512
|
-
ready: blockers.length === 0,
|
|
513
|
-
blockers,
|
|
514
|
-
components,
|
|
515
|
-
rig,
|
|
516
|
-
variableSetId,
|
|
517
|
-
legacyInlineSkillCount: pack.skills.length,
|
|
518
|
-
legacySandboxImage: pack.sandboxImage ?? null,
|
|
519
|
-
};
|
|
520
|
-
}
|
|
521
|
-
|
|
522
|
-
async function resolvePackRig(
|
|
523
|
-
db: Database,
|
|
524
|
-
workspaceId: string,
|
|
525
|
-
pack: CapabilityPack,
|
|
526
|
-
requestedRigId: string | undefined,
|
|
527
|
-
storedRigId: string | null | undefined,
|
|
528
|
-
): Promise<PackRigResolution> {
|
|
529
|
-
const required = pack.rig?.required === true || Boolean(pack.sandboxImage);
|
|
530
|
-
const selectedRigId = pack.rig?.rigId ?? requestedRigId ?? storedRigId ?? null;
|
|
531
|
-
if (!required && !selectedRigId) {
|
|
532
|
-
return {
|
|
533
|
-
required: false,
|
|
534
|
-
status: "not_required",
|
|
535
|
-
requestedRigId: requestedRigId ?? null,
|
|
536
|
-
rigId: null,
|
|
537
|
-
rigVersionId: null,
|
|
538
|
-
name: null,
|
|
539
|
-
image: null,
|
|
540
|
-
};
|
|
541
|
-
}
|
|
542
|
-
if (pack.rig?.rigId && requestedRigId && pack.rig.rigId !== requestedRigId) {
|
|
543
|
-
return {
|
|
544
|
-
required,
|
|
545
|
-
status: "mismatch",
|
|
546
|
-
requestedRigId,
|
|
547
|
-
rigId: pack.rig.rigId,
|
|
548
|
-
rigVersionId: null,
|
|
549
|
-
name: null,
|
|
550
|
-
image: null,
|
|
551
|
-
};
|
|
552
|
-
}
|
|
553
|
-
if (!selectedRigId) {
|
|
554
|
-
return {
|
|
555
|
-
required,
|
|
556
|
-
status: "missing",
|
|
557
|
-
requestedRigId: requestedRigId ?? null,
|
|
558
|
-
rigId: null,
|
|
559
|
-
rigVersionId: null,
|
|
560
|
-
name: null,
|
|
561
|
-
image: null,
|
|
562
|
-
};
|
|
563
|
-
}
|
|
564
|
-
const rig = await getRig(db, workspaceId, selectedRigId);
|
|
565
|
-
if (!rig?.activeVersion) {
|
|
566
|
-
return {
|
|
567
|
-
required,
|
|
568
|
-
status: "missing",
|
|
569
|
-
requestedRigId: requestedRigId ?? null,
|
|
570
|
-
rigId: selectedRigId,
|
|
571
|
-
rigVersionId: null,
|
|
572
|
-
name: rig?.name ?? null,
|
|
573
|
-
image: null,
|
|
574
|
-
};
|
|
575
|
-
}
|
|
576
|
-
// Explicit Rig images are disabled: a selected Rig always composes on the
|
|
577
|
-
// deployment platform base. Historical image values remain stored but are
|
|
578
|
-
// neither effective runtime truth nor a valid v2 Pack compatibility target.
|
|
579
|
-
const image = null;
|
|
580
|
-
const status = pack.sandboxImage
|
|
581
|
-
? "mismatch"
|
|
582
|
-
: pack.rig?.requireVerified && rig.activeVersionHealth?.checkHealth !== "passing"
|
|
583
|
-
? "unverified"
|
|
584
|
-
: "ready";
|
|
585
|
-
return {
|
|
586
|
-
required,
|
|
587
|
-
status,
|
|
588
|
-
requestedRigId: requestedRigId ?? null,
|
|
589
|
-
rigId: rig.id,
|
|
590
|
-
rigVersionId: rig.activeVersion.id,
|
|
591
|
-
name: rig.name,
|
|
592
|
-
image,
|
|
593
|
-
};
|
|
594
|
-
}
|
|
595
|
-
|
|
596
|
-
function packRigBlocker(rig: PackRigResolution, legacyImage: string | null): string {
|
|
597
|
-
if (rig.status === "missing") {
|
|
598
|
-
return "Choose an available compute environment before installing this Pack";
|
|
599
|
-
}
|
|
600
|
-
if (rig.status === "unverified") {
|
|
601
|
-
return "Verify the selected compute environment before installing this Pack";
|
|
602
|
-
}
|
|
603
|
-
if (legacyImage) {
|
|
604
|
-
return `This Pack requires the retired explicit sandbox image ${legacyImage}; Rig-bound Packs currently must use the deployment-managed platform sandbox`;
|
|
605
|
-
}
|
|
606
|
-
return "The selected compute environment does not satisfy this Pack's requirement";
|
|
607
|
-
}
|
|
608
|
-
|
|
609
|
-
function storedVariableSetId(metadata: Record<string, unknown> | undefined): string | null {
|
|
610
|
-
const value = metadata?.variableSetId ?? metadata?.environmentId;
|
|
611
|
-
return typeof value === "string" && value.length > 0 ? value : null;
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
/**
|
|
615
|
-
* v1 pack-scoped runtime rule: at most one enabled pack per workspace may
|
|
616
|
-
* declare a `sandboxImage` — there is deliberately no image composition or
|
|
617
|
-
* layering. Enforced when a pack is enabled (both the packs endpoint and the
|
|
618
|
-
* generic capability enable path) and re-checked at session start by the
|
|
619
|
-
* worker, which also covers manifests re-registered after enablement.
|
|
620
|
-
*/
|
|
621
|
-
export async function assertPackSandboxImageCompatible(
|
|
622
|
-
db: Database,
|
|
623
|
-
workspaceId: string,
|
|
624
|
-
pack: CapabilityPack,
|
|
625
|
-
): Promise<void> {
|
|
626
|
-
if (!pack.sandboxImage) {
|
|
627
|
-
return;
|
|
628
|
-
}
|
|
629
|
-
const installations = await listPackInstallations(db, workspaceId);
|
|
630
|
-
for (const installation of installations) {
|
|
631
|
-
if (installation.status !== "active" || installation.packId === pack.id) {
|
|
632
|
-
continue;
|
|
633
|
-
}
|
|
634
|
-
const other = await resolveCapabilityPack(db, workspaceId, installation.packId);
|
|
635
|
-
if (other?.sandboxImage) {
|
|
636
|
-
throw new HTTPException(409, {
|
|
637
|
-
message: `pack ${pack.id} declares a sandbox image, but enabled pack ${other.id} already declares one; only one enabled pack per workspace may declare sandboxImage — disable ${other.id} first`,
|
|
638
|
-
});
|
|
639
|
-
}
|
|
640
|
-
}
|
|
641
|
-
}
|
|
642
|
-
|
|
643
|
-
export function buildMarketingDailyAnalysisAgentConfig(input: {
|
|
644
|
-
connections: SocialConnection[];
|
|
645
|
-
documentBaseIds: string[];
|
|
646
|
-
promptInstructions?: string;
|
|
647
|
-
}): ScheduledTaskAgentConfig {
|
|
648
|
-
const connectionIds = input.connections.map((connection) => connection.id);
|
|
649
|
-
return {
|
|
650
|
-
prompt: marketingDailyAnalysisPrompt({
|
|
651
|
-
connections: input.connections,
|
|
652
|
-
documentBaseIds: input.documentBaseIds,
|
|
653
|
-
...(input.promptInstructions ? { promptInstructions: input.promptInstructions } : {}),
|
|
654
|
-
}),
|
|
655
|
-
resources: [],
|
|
656
|
-
tools: marketingSocialPack.tools,
|
|
657
|
-
metadata: {
|
|
658
|
-
packId: MARKETING_SOCIAL_PACK_ID,
|
|
659
|
-
packTemplateId: "daily-social-analysis",
|
|
660
|
-
socialConnectionIds: connectionIds,
|
|
661
|
-
documentBaseIds: input.documentBaseIds,
|
|
662
|
-
analysisWindowHours: 24,
|
|
663
|
-
},
|
|
664
|
-
};
|
|
665
|
-
}
|
|
666
|
-
|
|
667
|
-
function marketingDailyAnalysisPrompt(input: {
|
|
668
|
-
connections: SocialConnection[];
|
|
669
|
-
documentBaseIds: string[];
|
|
670
|
-
promptInstructions?: string;
|
|
671
|
-
}): string {
|
|
672
|
-
const connectionLines = input.connections
|
|
673
|
-
.map((connection) => {
|
|
674
|
-
return `- ${connection.provider}: ${connection.accountHandle} (${connection.id})`;
|
|
675
|
-
})
|
|
676
|
-
.join("\n");
|
|
677
|
-
const knowledgeLine =
|
|
678
|
-
input.documentBaseIds.length > 0
|
|
679
|
-
? `Use these document base IDs for brand/campaign knowledge through the docs MCP: ${input.documentBaseIds.join(", ")}.`
|
|
680
|
-
: "No document base IDs were selected; rely only on social context returned by tools.";
|
|
681
|
-
const extra = input.promptInstructions
|
|
682
|
-
? `\nAdditional operator instructions:\n${input.promptInstructions.trim()}\n`
|
|
683
|
-
: "";
|
|
684
|
-
|
|
685
|
-
return [
|
|
686
|
-
"Run the daily social media analysis for the selected accounts.",
|
|
687
|
-
"",
|
|
688
|
-
"First call the OpenGeni MCP tool social_daily_analysis_context with the selected connection IDs and a 24 hour analysis window. Use social_posts_recent only if you need a narrower follow-up query.",
|
|
689
|
-
knowledgeLine,
|
|
690
|
-
"",
|
|
691
|
-
"Selected accounts:",
|
|
692
|
-
connectionLines,
|
|
693
|
-
extra,
|
|
694
|
-
"Produce a concise report with these sections: executive summary, notable account changes, winning posts, underperforming posts, audience and content signals, recommended actions for the next 24 hours, and data gaps.",
|
|
695
|
-
"Use only metrics and posts returned by tools or document search. Do not invent metrics, posts, or account capabilities.",
|
|
696
|
-
]
|
|
697
|
-
.filter(Boolean)
|
|
698
|
-
.join("\n");
|
|
699
|
-
}
|