@opengeni/worker-bundle 1.0.1-canary.3 → 1.0.1-canary.35131097657002

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.
Files changed (29) hide show
  1. package/dist/activities/agent-turn/run-credentials.d.ts +0 -1
  2. package/dist/activities/agent-turn/tool-environment.d.ts +0 -2
  3. package/dist/activities/mcp-credentials.d.ts +10 -13
  4. package/dist/activities/mcp-operation-authority.d.ts +0 -5
  5. package/dist/activities/types.d.ts +1 -1
  6. package/dist/{activities-control-FNC52DPR.js → activities-control-2UZG6G5N.js} +90 -79
  7. package/dist/activities-control-2UZG6G5N.js.map +1 -0
  8. package/dist/{activities-turn-TQ3D6UE2.js → activities-turn-DHDXGKVY.js} +40 -170
  9. package/dist/activities-turn-DHDXGKVY.js.map +1 -0
  10. package/dist/{chunk-ECDL2TV4.js → chunk-73AMKEFQ.js} +2 -4
  11. package/dist/{chunk-ECDL2TV4.js.map → chunk-73AMKEFQ.js.map} +1 -1
  12. package/dist/index.js +1 -1
  13. package/dist/workflow-bundle.js +1 -1
  14. package/package.json +19 -19
  15. package/src/activities/agent-turn/failure-settlement.ts +10 -0
  16. package/src/activities/agent-turn/history.ts +12 -4
  17. package/src/activities/agent-turn/run-credentials.ts +3 -7
  18. package/src/activities/agent-turn/run.ts +0 -3
  19. package/src/activities/agent-turn/tool-environment.ts +0 -11
  20. package/src/activities/google-drive-publication.ts +1 -3
  21. package/src/activities/mcp-credentials.ts +34 -198
  22. package/src/activities/mcp-operation-authority.ts +16 -41
  23. package/src/activities/scheduled-tasks.ts +100 -89
  24. package/src/activities/types.ts +1 -0
  25. package/src/github-rest-mcp.ts +0 -1
  26. package/src/personal-github-git-credentials.ts +0 -1
  27. package/src/pr-review-credentials.ts +0 -2
  28. package/dist/activities-control-FNC52DPR.js.map +0 -1
  29. package/dist/activities-turn-TQ3D6UE2.js.map +0 -1
@@ -54,7 +54,6 @@ export declare function prepareRunCredentials(deps: PrepareRunCredentialsDeps):
54
54
  initialRunCredentialMaterial: NormalizedRunCredentialMaterial | null;
55
55
  runCredentialsNote: string | undefined;
56
56
  authorizeGitHubTokenMint: GitHubTokenMintAuthorization;
57
- hostCredentialRootSessionId: string | null;
58
57
  gitCredentialAuthority: import("../environment.js").GitCredentialAuthority | undefined;
59
58
  codemodeAuthority: {
60
59
  sessionId: string;
@@ -34,7 +34,6 @@ export type PrepareTurnToolRuntimeDeps = {
34
34
  objectStorage: ActivityServices["objectStorage"];
35
35
  observability: ActivityServices["observability"];
36
36
  cancellationSignal: AbortSignal | undefined;
37
- connectionCredentials: ActivityServices["connectionCredentials"];
38
37
  eventing: EventingState;
39
38
  attempt: AttemptIdentityState;
40
39
  sandboxState: SandboxRuntimeState;
@@ -55,7 +54,6 @@ export type PrepareTurnToolRuntimeDeps = {
55
54
  accountId: string;
56
55
  workspaceId: string;
57
56
  };
58
- hostCredentialRootSessionId: string | null;
59
57
  sandboxArtifactRuntime: ReturnType<typeof sandboxArtifactRuntimeAdmission>;
60
58
  activeSandboxBackend: Settings["sandboxBackend"] | undefined;
61
59
  groupBoxBackend: Settings["sandboxBackend"];
@@ -1,22 +1,19 @@
1
1
  import type { Settings } from "@opengeni/config";
2
- import type { ConnectionCredentialsPort } from "@opengeni/contracts";
3
- import { getSessionTurnForAttempt, resolveAcceptedConnectionUse, sessionTenancyProductActivated, type Database, type ResolveConnectionCredentialInput, type ResolveConnectionCredentialResult, type SessionTurnForExecution } from "@opengeni/db";
4
- import { type Observability } from "@opengeni/observability";
5
- export declare function connectionTokenResolverForTurn(input: {
2
+ import { resolveAcceptedConnectionUse, type Database, type ResolveConnectionCredentialInput, type ResolveConnectionCredentialResult, type SessionTurnForExecution } from "@opengeni/db";
3
+ type TurnConnectionInput = {
6
4
  db: Database;
7
5
  settings: Settings;
8
- connectionCredentials?: ConnectionCredentialsPort | null;
9
6
  accountId: string;
10
7
  workspaceId: string;
11
8
  sessionId: string;
12
- rootSessionId: string;
13
9
  attemptId: string;
14
10
  turn: SessionTurnForExecution;
15
11
  authorizeAcceptedUse?: typeof resolveAcceptedConnectionUse;
16
- /** Test seam; production always reads the canonical active-attempt projection. */
17
- getHostTurnForAttempt?: typeof getSessionTurnForAttempt;
18
- /** Test seam for the activation fence on pre-snapshot workspace refs. */
19
- isSessionTenancyProductActivated?: typeof sessionTenancyProductActivated;
20
- /** Optional; used only for content-free compatibility-lane counters. */
21
- observability?: Observability | null | undefined;
22
- }): (request: ResolveConnectionCredentialInput) => Promise<ResolveConnectionCredentialResult>;
12
+ };
13
+ type CredentialResolver = (request: ResolveConnectionCredentialInput) => Promise<ResolveConnectionCredentialResult>;
14
+ export declare function connectionTokenResolverForTurn(input: TurnConnectionInput): CredentialResolver;
15
+ /** Bind the ordinary credential resolver to one immutable accepted turn.
16
+ * Credential acquisition and refresh stay inside the native connection engine;
17
+ * this layer adds the exact execution context and physical-request checks. */
18
+ export declare function bindNativeConnectionCredentialsToTurn(input: TurnConnectionInput, nativeResolver: CredentialResolver): CredentialResolver;
19
+ export {};
@@ -1,16 +1,11 @@
1
1
  import type { ConnectionUseAttribution } from "@opengeni/contracts/connection-authority";
2
- import type { HostMcpAcceptedAuthority } from "@opengeni/contracts/host-mcp-bindings";
3
2
  import type { ResolveConnectionCredentialInput } from "@opengeni/db";
4
3
  /** Metadata only. Callers must obtain authority from a current live fence.
5
4
  * This equality key is never authorization and never replaces physical-use checks. */
6
5
  export declare function mcpOperationAuthorityDigest(request: ResolveConnectionCredentialInput, authority: {
7
6
  native: ConnectionUseAttribution;
8
- host?: never;
9
7
  principal?: {
10
8
  kind: string;
11
9
  subjectId?: string;
12
10
  };
13
- } | {
14
- host: HostMcpAcceptedAuthority;
15
- native?: never;
16
11
  }): string;
@@ -334,7 +334,7 @@ export type DispatchScheduledTaskRunResult = {
334
334
  action: "deleted";
335
335
  } | {
336
336
  action: "blocked";
337
- reason: "insufficient_credits" | "monthly_model_cost_limit" | "monthly_agent_run_limit" | "malformed_manual_trigger" | "scheduled_task_paused" | "scheduled_authority_exhausted" | "scheduled_run_terminal" | "scheduled_execution_unrepresentable" | "knowledge_source_paused" | "legacy_source_schedule_requires_migration" | "incident_preflight_metadata_missing" | "incident_responder_under_capable" | "incident_data_source_unsuitable";
337
+ reason: "insufficient_credits" | "monthly_model_cost_limit" | "monthly_agent_run_limit" | "malformed_manual_trigger" | "scheduled_task_paused" | "scheduled_authority_exhausted" | "scheduled_run_terminal" | "scheduled_execution_unrepresentable" | "connection_account_unavailable" | "knowledge_source_paused" | "legacy_source_schedule_requires_migration" | "incident_preflight_metadata_missing" | "incident_responder_under_capable" | "incident_data_source_unsuitable";
338
338
  } | {
339
339
  action: "start" | "signal";
340
340
  accountId: string;
@@ -33,7 +33,7 @@ import {
33
33
  scheduledUserMessagePayload,
34
34
  withFirstPartyTools,
35
35
  workflowIdForSession
36
- } from "./chunk-ECDL2TV4.js";
36
+ } from "./chunk-73AMKEFQ.js";
37
37
  import {
38
38
  inspectOpenSandboxKubernetesInventory,
39
39
  recordCreditBalanceGauges,
@@ -4480,7 +4480,6 @@ import {
4480
4480
  TurnExecutionPolicyV1
4481
4481
  } from "@opengeni/contracts";
4482
4482
  import {
4483
- defaultSessionMcpServerIds,
4484
4483
  openGeniSlackBotMetadata,
4485
4484
  requireOpenGeniSlackBotConnection,
4486
4485
  resolveWorkspaceCatalogSettings as resolveWorkspaceCatalogSettings2,
@@ -4488,6 +4487,12 @@ import {
4488
4487
  workspaceCustomModelReference,
4489
4488
  lockActiveCustomModelForAdmission,
4490
4489
  scheduledSlackBotConnectionId,
4490
+ freezePersonalConnectionDelegations,
4491
+ ConnectionAccountSelectionError,
4492
+ scheduledConnectionSurfaceEligibility,
4493
+ scheduledConnectionTools,
4494
+ settingsWithEnabledCapabilityMcpServers,
4495
+ settingsWithSessionMcpServerMetadata,
4491
4496
  swapActiveSandbox
4492
4497
  } from "@opengeni/core";
4493
4498
  import {
@@ -4502,7 +4507,6 @@ import {
4502
4507
  getScheduledTaskRunAcceptedExecution,
4503
4508
  getScheduledTaskRunByProducerKey,
4504
4509
  getScheduledTargetSessionExecution,
4505
- getScheduledTaskPersonalConnectionDelegations,
4506
4510
  getScheduledTaskRunPersonalResourceAuthority,
4507
4511
  getScheduledTaskPersonalResourceAuthoritySubject,
4508
4512
  getScheduledTaskRevisionAuthority,
@@ -4518,7 +4522,6 @@ import {
4518
4522
  isCodexBilledModel,
4519
4523
  initializeSessionStartAtomically,
4520
4524
  materializeScheduledTaskReusableSessionFromRun,
4521
- listEnabledMcpCapabilityServerIds,
4522
4525
  listInstalledApiIntegrationServerIdsForDelegations,
4523
4526
  markScheduledTaskRunFailedIfQueued,
4524
4527
  markScheduledTaskRunSkippedIfQueued,
@@ -4818,20 +4821,6 @@ function createScheduledTaskActivities(services) {
4818
4821
  if (incidentDeclaration.action === "blocked") {
4819
4822
  return incidentDeclaration;
4820
4823
  }
4821
- const taskPersonalConnectionDelegations = await getScheduledTaskPersonalConnectionDelegations(
4822
- db,
4823
- task.workspaceId,
4824
- task.id
4825
- );
4826
- const taskConnectionAuthoritySubjects = [
4827
- ...new Set(
4828
- taskPersonalConnectionDelegations.map((delegation) => delegation.ownerSubjectId)
4829
- )
4830
- ];
4831
- if (taskConnectionAuthoritySubjects.length > 1) {
4832
- throw new Error("scheduled connection authority has multiple causal humans");
4833
- }
4834
- const taskConnectionAuthoritySubjectId = taskConnectionAuthoritySubjects[0] ?? null;
4835
4824
  const taskPersonalResourceAuthoritySubjectId = await getScheduledTaskPersonalResourceAuthoritySubject(db, {
4836
4825
  accountId: task.accountId,
4837
4826
  workspaceId: task.workspaceId,
@@ -4844,10 +4833,12 @@ function createScheduledTaskActivities(services) {
4844
4833
  taskId: task.id,
4845
4834
  taskAuthorityRevision: task.authorityRevision
4846
4835
  });
4847
- if (taskConnectionAuthoritySubjectId && taskPersonalResourceAuthoritySubjectId && taskConnectionAuthoritySubjectId !== taskPersonalResourceAuthoritySubjectId) {
4848
- throw new Error("scheduled authority classes have different causal humans");
4836
+ const taskAuthoritySubjectId = task.ownerSubjectId;
4837
+ if (task.action.kind === "agent_turn" && ((taskRevisionAuthority?.subjectId ?? null) !== taskAuthoritySubjectId || [taskPersonalResourceAuthoritySubjectId].some(
4838
+ (subject) => subject !== null && subject !== taskAuthoritySubjectId
4839
+ ))) {
4840
+ throw new Error("scheduled authority differs from its immutable execution owner");
4849
4841
  }
4850
- const taskAuthoritySubjectId = taskRevisionAuthority?.subjectId ?? taskPersonalResourceAuthoritySubjectId ?? taskConnectionAuthoritySubjectId;
4851
4842
  const acceptedTargetSessionId = task.runMode === "existing_session" ? task.targetSessionId : task.runMode === "reusable_session" ? task.reusableSessionId : null;
4852
4843
  const targetSessionExecutionBase = acceptedTargetSessionId ? await getScheduledTargetSessionExecution(
4853
4844
  db,
@@ -4864,6 +4855,44 @@ function createScheduledTaskActivities(services) {
4864
4855
  const creatorPolicy = await getScheduledTaskCreatorPolicy(db, task.workspaceId, task.id);
4865
4856
  const firstPartyMcpTools = creatorPolicy?.firstPartyMcpTools ? allowedFirstPartyMcpToolsForSession(settings, creatorPolicy.firstPartyMcpTools) : resolveFirstPartyMcpToolPolicy(settings).default;
4866
4857
  const firstPartyMcpPermissions = creatorPolicy?.firstPartyMcpPermissions ? [...creatorPolicy.firstPartyMcpPermissions] : [...DEFAULT_FIRST_PARTY_MCP_PERMISSIONS];
4858
+ const connectionSettings = await settingsWithEnabledCapabilityMcpServers(
4859
+ db,
4860
+ task.workspaceId,
4861
+ settings,
4862
+ taskAuthoritySubjectId ? { subjectId: taskAuthoritySubjectId } : {}
4863
+ );
4864
+ const connectionTarget = acceptedTargetSessionId && targetSessionExecutionBase ? await requireSession(db, task.workspaceId, acceptedTargetSessionId) : null;
4865
+ const connectionTools = await scheduledConnectionTools(
4866
+ db,
4867
+ task.workspaceId,
4868
+ connectionSettings,
4869
+ connectionTarget,
4870
+ taskTools,
4871
+ taskAuthoritySubjectId ?? void 0
4872
+ );
4873
+ const taskPersonalConnectionDelegations = await freezePersonalConnectionDelegations({
4874
+ db,
4875
+ workspaceId: task.workspaceId,
4876
+ settings: connectionTarget ? settingsWithSessionMcpServerMetadata(connectionSettings, connectionTarget.mcpServers) : connectionSettings,
4877
+ tools: connectionTools,
4878
+ resources: connectionTarget?.resources ?? task.agentConfig.resources,
4879
+ source: taskAuthoritySubjectId ? { kind: "subject", subjectId: taskAuthoritySubjectId, accountId: task.accountId } : { kind: "none" },
4880
+ authoritySelections: task.agentConfig.connectionAccounts ?? [],
4881
+ ...scheduledConnectionSurfaceEligibility(
4882
+ settings,
4883
+ connectionTarget ?? {
4884
+ firstPartyMcpTools,
4885
+ firstPartyMcpPermissions
4886
+ }
4887
+ )
4888
+ }).catch((error) => {
4889
+ if (error instanceof ConnectionAccountSelectionError) return null;
4890
+ throw error;
4891
+ });
4892
+ if (taskPersonalConnectionDelegations === null) {
4893
+ return { action: "blocked", reason: "connection_account_unavailable" };
4894
+ }
4895
+ const taskConnectionAuthoritySubjectId = taskPersonalConnectionDelegations.length > 0 ? taskAuthoritySubjectId : null;
4867
4896
  const creatorSessionPolicy = scheduledCreatorSessionPolicyInput(
4868
4897
  creatorPolicy?.sessionPolicy ?? null
4869
4898
  );
@@ -4911,20 +4940,15 @@ function createScheduledTaskActivities(services) {
4911
4940
  };
4912
4941
  })() : null;
4913
4942
  const targetSessionExecution = targetSessionExecutionBase ? await (async () => {
4914
- const [capabilityServerIds, apiIntegrationServerIds] = await Promise.all([
4915
- listEnabledMcpCapabilityServerIds(db, task.workspaceId),
4916
- listInstalledApiIntegrationServerIdsForDelegations(
4917
- db,
4918
- task.workspaceId,
4919
- taskPersonalConnectionDelegations
4920
- )
4921
- ]);
4922
- const workspaceDefaultMcpServerIds = new Set(
4923
- settings.mcpServers.map((server) => server.id)
4943
+ const apiIntegrationServerIds = await listInstalledApiIntegrationServerIdsForDelegations(
4944
+ db,
4945
+ task.workspaceId,
4946
+ taskPersonalConnectionDelegations
4924
4947
  );
4925
- for (const id of capabilityServerIds) workspaceDefaultMcpServerIds.add(id);
4926
- for (const id of apiIntegrationServerIds) workspaceDefaultMcpServerIds.add(id);
4927
- const availableMcpServerIds = new Set(workspaceDefaultMcpServerIds);
4948
+ const availableMcpServerIds = /* @__PURE__ */ new Set([
4949
+ ...connectionSettings.mcpServers.map((server) => server.id),
4950
+ ...apiIntegrationServerIds
4951
+ ]);
4928
4952
  for (const id of targetSessionExecutionBase.mcpServerIds) {
4929
4953
  availableMcpServerIds.add(id);
4930
4954
  }
@@ -4932,9 +4956,10 @@ function createScheduledTaskActivities(services) {
4932
4956
  toolPolicy: targetSessionExecutionBase.toolPolicy,
4933
4957
  sessionTools: targetSessionExecutionBase.tools,
4934
4958
  availableMcpServerIds,
4935
- defaultMcpServerIds: defaultSessionMcpServerIds(
4936
- [...workspaceDefaultMcpServerIds].map((id) => ({ id }))
4937
- )
4959
+ defaultMcpServerIds: [
4960
+ ...connectionTools.map((tool) => tool.id),
4961
+ ...apiIntegrationServerIds
4962
+ ]
4938
4963
  });
4939
4964
  return {
4940
4965
  ...targetSessionExecutionBase,
@@ -5256,13 +5281,7 @@ function createScheduledTaskActivities(services) {
5256
5281
  taskId: task.id
5257
5282
  }
5258
5283
  );
5259
- if (stableJson({
5260
- task: exactAuthority.task,
5261
- personalConnectionDelegations: exactAuthority.personalConnectionDelegations
5262
- }) !== stableJson({
5263
- task,
5264
- personalConnectionDelegations: taskPersonalConnectionDelegations
5265
- })) {
5284
+ if (stableJson(exactAuthority) !== stableJson(task)) {
5266
5285
  throw new IncidentTelemetryPreflightBlockedError(
5267
5286
  "incident_preflight_metadata_missing"
5268
5287
  );
@@ -5954,46 +5973,38 @@ function scheduledSessionRejectionError(rejectionReason) {
5954
5973
  }
5955
5974
  async function prepareIncidentTelemetrySource(input) {
5956
5975
  const session = await requireSession(input.tx, input.workspaceId, input.sessionId);
5957
- const { task, personalConnectionDelegations } = input.acceptedExecution ? {
5958
- task: input.acceptedExecution.task,
5959
- personalConnectionDelegations: input.acceptedExecution.personalConnectionDelegations
5960
- } : await requireScheduledTaskIncidentAuthorityInTransaction(input.tx, {
5961
- workspaceId: input.workspaceId,
5962
- taskId: input.taskId
5963
- });
5976
+ const { task, personalConnectionDelegations } = input.acceptedExecution;
5964
5977
  const responder = await resolveIncidentTelemetryResponderMetadata({
5965
5978
  db: input.tx,
5966
5979
  settings: input.settings,
5967
5980
  task,
5968
5981
  session,
5969
5982
  personalConnectionDelegations,
5970
- personalResourceAuthoritySubjectId: input.acceptedExecution?.personalResourceAuthoritySubjectId ?? null,
5971
- ...input.acceptedExecution ? {
5972
- executionPolicy: input.acceptedExecution.targetSessionExecution ? {
5973
- tools: input.acceptedExecution.targetSessionExecution.tools,
5974
- firstPartyMcpTools: input.acceptedExecution.targetSessionExecution.firstPartyMcpTools,
5975
- firstPartyMcpPermissions: input.acceptedExecution.targetSessionExecution.firstPartyMcpPermissions,
5976
- variableSetIds: input.acceptedExecution.targetSessionExecution.variableSets.map(
5977
- (variableSet) => variableSet.id
5978
- ),
5979
- variableSetId: input.acceptedExecution.targetSessionExecution.variableSetId,
5980
- rigId: input.acceptedExecution.targetSessionExecution.rigId,
5981
- rigVersionId: input.acceptedExecution.targetSessionExecution.rigVersionId,
5982
- toolPolicy: input.acceptedExecution.targetSessionExecution.toolPolicy,
5983
- mcpServerIds: input.acceptedExecution.targetSessionExecution.mcpServerIds,
5984
- toolPolicyVersion: input.acceptedExecution.targetSessionExecution.toolPolicyVersion
5985
- } : {
5986
- tools: input.acceptedExecution.resolvedTools,
5987
- firstPartyMcpTools: input.acceptedExecution.resolvedFirstPartyMcpTools,
5988
- firstPartyMcpPermissions: input.acceptedExecution.resolvedFirstPartyMcpPermissions,
5989
- variableSetId: input.acceptedExecution.resolvedVariableSet?.id ?? null,
5990
- rigId: input.acceptedExecution.resolvedRig?.id ?? null,
5991
- rigVersionId: input.acceptedExecution.resolvedRig?.versionId ?? null,
5992
- toolPolicy: session.toolPolicy,
5993
- mcpServerIds: [],
5994
- toolPolicyVersion: session.toolPolicyVersion
5995
- }
5996
- } : {}
5983
+ personalResourceAuthoritySubjectId: input.acceptedExecution.personalResourceAuthoritySubjectId ?? null,
5984
+ executionPolicy: input.acceptedExecution.targetSessionExecution ? {
5985
+ tools: input.acceptedExecution.targetSessionExecution.tools,
5986
+ firstPartyMcpTools: input.acceptedExecution.targetSessionExecution.firstPartyMcpTools,
5987
+ firstPartyMcpPermissions: input.acceptedExecution.targetSessionExecution.firstPartyMcpPermissions,
5988
+ variableSetIds: input.acceptedExecution.targetSessionExecution.variableSets.map(
5989
+ (variableSet) => variableSet.id
5990
+ ),
5991
+ variableSetId: input.acceptedExecution.targetSessionExecution.variableSetId,
5992
+ rigId: input.acceptedExecution.targetSessionExecution.rigId,
5993
+ rigVersionId: input.acceptedExecution.targetSessionExecution.rigVersionId,
5994
+ toolPolicy: input.acceptedExecution.targetSessionExecution.toolPolicy,
5995
+ mcpServerIds: input.acceptedExecution.targetSessionExecution.mcpServerIds,
5996
+ toolPolicyVersion: input.acceptedExecution.targetSessionExecution.toolPolicyVersion
5997
+ } : {
5998
+ tools: input.acceptedExecution.resolvedTools,
5999
+ firstPartyMcpTools: input.acceptedExecution.resolvedFirstPartyMcpTools,
6000
+ firstPartyMcpPermissions: input.acceptedExecution.resolvedFirstPartyMcpPermissions,
6001
+ variableSetId: input.acceptedExecution.resolvedVariableSet?.id ?? null,
6002
+ rigId: input.acceptedExecution.resolvedRig?.id ?? null,
6003
+ rigVersionId: input.acceptedExecution.resolvedRig?.versionId ?? null,
6004
+ toolPolicy: session.toolPolicy,
6005
+ mcpServerIds: [],
6006
+ toolPolicyVersion: session.toolPolicyVersion
6007
+ }
5997
6008
  });
5998
6009
  const preflight = evaluateIncidentTelemetryPreflight({
5999
6010
  agentConfig: task.agentConfig,
@@ -7317,4 +7328,4 @@ export {
7317
7328
  createControlActivities,
7318
7329
  createControlActivitiesFromServices
7319
7330
  };
7320
- //# sourceMappingURL=activities-control-FNC52DPR.js.map
7331
+ //# sourceMappingURL=activities-control-2UZG6G5N.js.map